gpt4 book ai didi

android - nexus 7上的新android Camera2 Api

转载 作者:太空宇宙 更新时间:2023-11-03 12:18:03 33 4
gpt4 key购买 nike

我在 Nexus 7 上遇到了 android Camera2 API 的问题。我在 android 4.4.4 上开发了一个应用程序,它使用相机拍照,我想为 Lollipop 更新更新它。我已经按照此链接中的代码使新的相机 api 工作:https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java

我已经在 Nexus 5 上测试了代码,一切正常,但如果我在 Nexus 7 上尝试,就会出现问题。这是错误日志:

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

抛出异常的行是:

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

出了什么问题?

最佳答案

Nexus 7 在使用新的 camera2 API 时是 LEGACY 级别的设备,而 LEGACY 设备相对于实现新 API 的 LIMITED 或 FULL 级别的设备有很多限制。

documentation对于 CONTROL_AE_STATE,有一条注释:

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

这意味着它不能保证在 LEGACY 设备中存在,事实上它不会存在,因为这些设备不会产生 AE 状态信息。

关于android - nexus 7上的新android Camera2 Api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27529852/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com