not do any less than every fifth row. Can you think why this is?
Change the "step 5" in the first "For" loop to any other lower value
I think that it may be that the picture size is not 640x480. How can I force it to be that?
640x480 is the default for some android device cameras, but not for all, so this may be the case. You can modify the Camera1_Ready Sub to force it and show in the screen the real preview size.
Sub Camera1_Ready (Success As Boolean)
If Success Then
camEx.SetJpegQuality(90)
camEx.SetContinuousAutoFocus
camEx.SetPreviewSize(640,480) '<---- ADD THIS!!!!
camEx.CommitParameters
camEx.StartPreview
Log(camEx.GetPreviewSize)
ToastMessageShow(" Preview size is "& camEx.GetPreviewSize.Width & "," & camEx.GetPreviewSize.Height,True) '<--- ALSO ADD THIS LINE
Else
ToastMessageShow("Cannot open camera.", True)
End If
End Sub
Tried camEx.SetPictureSize(640,480) but it brought up a java exception when run
This command is not for preview size but for the taken picture size. They are different things
About this line...
luminance = PreviewPic( 640*row + col)
I don't think it is correct. It will give you problems. PreviewPic is a byte array. In B4A and Android, bytes are signed. It is no problem if you only use it as a container for data that you know that are unsigned, but if you compare them (in this case they are being compared to luminance), then the sign matters.
I mean, a normal point, when detected by the camera, can have a luminance of 100. It is a value 0x64 (in hexa) ..> as it is lower than 128, then it can be taken directly compared to luminance.
But if we have a bright point with a luminance of 192, that is 0xC0 in hexa.--> as it is stored in a byte, if you get its value it will be interpreted as negative. Then, when you compare it to the luminance threshold, the comparison will never be good.
.Even if it is slower, I would change that line and put instead again
luminance = Bit.And( PreviewPic(640*row+col),0xFF) '<-- It will give you an integer and always positive.