jjlangley
jjlangley

Reputation: 31

Unable to focus on nearby objects

I'm having difficulties with the Camera2 API's in regards to autofocus. I am trying to snap pictures of objects at about 6-8" range, specifically, a bank check, however, until the object is at approximately 12" range, the text on the check is very blurry and it doesn't seem that the device's autofocus is working properly. When I use the device's built-in Camera application, I don't have this issue at all.

The blurriness is present in both the preview and captured still image.

I'm using code from https://github.com/googlesamples/android-Camera2Basic , and have been playing with all of the autofocus settings I can think to try, and so far none have worked.

This is on a Samsung Galaxy S5. Unfortunately I don't have any other Android 5 devices to try it out on right now.

How can I achieve smooth focus on such items similar to the native Camera app?

Upvotes: 2

Views: 992

Answers (2)

jjlangley
jjlangley

Reputation: 31

Alright, I believe I have the reason why this isn't working on the S5 based on some investigation as to how the default camera app code works as of API 22. It seems that as of right now, my device is considered as legacy (see https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL).

The default Android camera code falls back on the deprecated camera APIs when the device has anything less than INFO_SUPPORTED_HARDWARE_LEVEL_FULL. To me, this seems like some form of admission that Camera2 isn't quite ready for applications that must stably support a large base of devices. The old Camera API works perfectly, I was just trying to go with the recommendation of using Camera2 for new applications.

For anyone that comes across this in the future, check the status out of OneCamera - that looks like the direction the default camera is angling and it seems like the old PhotoModule code will eventually be deprecated or just wrap calls to OneCamera. For clarification... OneCamera is some code that currently seems to only exist within the Android camera app. This is located at: https://android.googlesource.com/platform/packages/apps/Camera.git . I was using the Lollipop release branch at the time.

Upvotes: 1

Eddy Talvala
Eddy Talvala

Reputation: 18137

Are you locking AF by issuing an AF_TRIGGER_START before taking the final image? Which AF modes did you try to use?

There is a minimum focus distance that the camera can succesfully focus at, but that's on the range of 10cm.

Upvotes: 0

Related Questions