I am developing an app which takes a preview of the device's camera and analyses that feed. I can create the camera preview, but cannot get the camera to adjust its focus automatically.
I know that the underlying hardware is possible of performing an auto focus because the native BlackBerry camera app responds to the 'take photo' media key by auto focussing the image prior to taking the photo.
However, I'm not trying to take a photo, I'm trying to continuously scan the input feed for a barcode.
Here's my code:
Player _player = Manager.createPlayer("capture://video");
_player.realize();
_player.start();
_vc = (VideoControl) _player.getControl("VideoControl");
//this is added to the screen
_viewFinder = (Field) _vc.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
FocusControl focusControl = (FocusControl) _player.getControl("javax.microedition.amms.control.camera.FocusControl");
//this has no effect
focusControl.setFocus(FocusControl.AUTO);
I have tested on BlackBerry Storm 9500 and Bold 9700 both running OS5.
The only way to focus the camera in OS5 is to use VideoControl.getSnapshot(). There is no other way.