In my Android app, the focus mode is set to FOCUS_MODE_CONTINUOUS_PICTURE.
. Here is some relevant code:
private Camera.AutoFocusCallback _cbAutoFocus = new Camera.AutoFocusCallback() {
private int _count = 0;
@Override
public void onAutoFocus(boolean success, Camera camera) {
if (success) {
_count++;
if ((_count % 500) == 0) {
Log.d("MyCam Focus", Integer.toString(_count));
}
_camera.cancelAutoFocus();
}
_camera.autoFocus(_cbAutoFocus);
}
};
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
try {
if (this._camera != null) {
this._camera.setPreviewDisplay(holder);
this._camera.startPreview();
this._camera.autoFocus(this._cbAutoFocus);
}
}catch(Exception e) {
Log.e("Camera Surface change", e.getMessage());
}
}
As I move the camera over some printed text, the camera seems to auto-focus properly for some time. However, after a while, it stops focusing and I don't get success as true in my onAutoFocus
code. Wondering if anyone has any insights. Regards.