Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new android Camera2 Api on nexus 7

I have a problem with android Camera2 API on a Nexus 7. I have developed an app on android 4.4.4 that uses the camera to take a picture, and I want to update it for the Lollipop update. I've followed code from this link to make new camera api work: https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java

I've tested code on a Nexus 5, and everything works well, but if i try it on a Nexus 7, something goes wrong. This is the error log:

12-17 17:01:15.517: W/LegacyRequestMapper(24382): convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
12-17 17:01:15.517: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
12-17 17:01:15.518: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
12-17 17:01:15.519: W/LegacyRequestMapper(24382): mapAeAndFlashMode - Ignore control.aeMode == ON_AUTO_FLASH;camera does not support it
12-17 17:01:15.519: W/LegacyRequestMapper(24382): convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
12-17 17:01:15.955: I/CameraDeviceState(24382): Legacy camera service transitioning to state CAPTURING
12-17 17:01:21.198: I/RequestQueue(24382): Repeating capture request cancelled.
12-17 17:01:21.198: I/RequestQueue(24382): Repeating capture request set.
12-17 17:01:21.215: W/LegacyRequestMapper(24382): convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
12-17 17:01:21.215: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
12-17 17:01:21.215: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
12-17 17:01:21.216: W/LegacyRequestMapper(24382): mapAeAndFlashMode - Ignore control.aeMode == ON_AUTO_FLASH;camera does not support it
12-17 17:01:21.216: W/LegacyRequestMapper(24382): convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
12-17 17:01:21.495: E/AndroidRuntime(24382): FATAL EXCEPTION: CameraBackground
12-17 17:01:21.495: E/AndroidRuntime(24382): Process: com.example.newapicamera, PID: 24382
12-17 17:01:21.495: E/AndroidRuntime(24382): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
12-17 17:01:21.495: E/AndroidRuntime(24382):    at com.example.newapicamera.Camera2BasicFragment$4.process(Camera2BasicFragment.java:285)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at com.example.newapicamera.Camera2BasicFragment$4.onCaptureCompleted(Camera2BasicFragment.java:324)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at java.lang.reflect.Method.invoke(Native Method)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at java.lang.reflect.Method.invoke(Method.java:372)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.os.Handler.handleCallback(Handler.java:739)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at  android.os.Handler.dispatchMessage(Handler.java:95)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.os.Looper.loop(Looper.java:135)
12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.os.HandlerThread.run(HandlerThread.java:61)
12-17 17:01:21.542: I/RequestQueue(24382): Repeating capture request cancelled.
12-17 17:01:21.580: E/BufferQueueProducer(24382): [unnamed-24382-2] dequeueBuffer: BufferQueue has been abandoned
12-17 17:01:21.580: E/BufferQueueProducer(24382): [unnamed-24382-2] dequeueBuffer: BufferQueue has been abandoned
12-17 17:01:21.596: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
12-17 17:01:21.605: W/Camera-JNI(24382): callback on dead camera object
12-17 17:01:21.620: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
12-17 17:01:21.651: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
12-17 17:01:21.688: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
12-17 17:01:21.721: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned

The line that throws the exception is:

int aeState = result.get(CaptureResult.CONTROL_AE_STATE);

What is going wrong?

like image 496
giozh Avatar asked Mar 18 '23 14:03

giozh


1 Answers

The Nexus 7 is a LEGACY-level device when using the new camera2 API, and LEGACY devices have many limitations relative to devices that implement either the LIMITED or FULL levels of the new API.

In the documentation for CONTROL_AE_STATE, there's a note:

Limited capability - Present on all camera devices that report being at least HARDWARE_LEVEL_LIMITED devices in the android.info.supportedHardwareLevel key

which means it's not guaranteed to be present for LEGACY devices, and in fact it won't be, as such devices don't produce AE state information.

like image 176
Eddy Talvala Avatar answered Mar 28 '23 18:03

Eddy Talvala