FOCUS_MODE_AUTO
should work well for OCR. You probably want to implement some kind of loop that periodically causes focus. Sample code for this can be found in the zxing project here .
FOCUS_MODE_CONTINUOUS_PICTURE
and especially FOCUS_MODE_CONTINUOUS_VIDEO
seem to work poorly - some devices do not seem to realize that the view is out of focus, leaving a blurry view.
To avoid blurry images, do not shoot a video frame for OCR during the autofocus cycle. Also keep in mind that the onAutoFocus()
can be called a bit before the autofocus cycle is really finished, so you can avoid immediately capturing the frame for OCR when you receive the callback because it may be blurry.
Another possibility is to use the blur detection algorithm to determine if the frames are blurry and to respond appropriately by requesting an autofocus cycle or capturing a new frame. It can be hard to get, though, without going overboard, rejecting frames that are slightly out of focus.
source share