Opencv camera and autofocus

2,275 views
Skip to first unread message

AlexG

unread,
May 5, 2012, 11:37:39 AM5/5/12
to android...@googlegroups.com
Hello guys,
I have a question regarding autofocus. Same code (with continuous autofocus set in camera parameters) works well on some devices (Sony Ericsson Xperia Mini pro) but on my device (Samsung Galaxy S2, Android 4.0.4) it refuses to autofocus. Why is that?
I got it to autofocus on the Samsung only by using the Android Camera (but the fps is very low when converting to RGB for some reason).
Is autofocus not supported in Opencv native camera?
Thank you.

Andrey Pavlenko

unread,
May 10, 2012, 10:21:24 AM5/10/12
to android...@googlegroups.com
On devices that support FOCUS_MODE_CONTINUOUS_VIDEO - it is set. 

AlexG

unread,
May 10, 2012, 4:48:19 PM5/10/12
to
Here is what logcat is saying:
05-10 23:36:57.530: D/OpenCV_NativeCamera(3905): initCameraConnect: autofocus is set to mode "continuous-video"
05-10 23:36:57.530: D/CameraWrapper(1871): camera_fixup_setparams: set parameters fixed up
05-10 23:36:57.530: D/SecCameraHardware(1871): int android::HAL_camera_device_set_parameters(camera_device*, const char*)
05-10 23:36:57.530: D/ISecCameraHardware(1871): setParameters X: success

As I understand, the way I set continuous autofocus is ok. Nevertheless it will not work.
Edit: And I also checked before setting this autofocus mode, it is listed as supported by Camera.

Alexander Smorkalov

unread,
May 11, 2012, 9:05:46 AM5/11/12
to android...@googlegroups.com
I check this problem on the same device with Android 4.0.3. It works fine.
OpenCV native camera sets parameters using the same interface as Java camera. Google says about Java camera:

This is the best choice for video recording because the focus changes smoothly. Applications still can call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback) in this mode but the subject may not be in focus.

Source: link

Smooth focus changes can be the root of the problem.
Reply all
Reply to author
Forward
0 new messages