0

我正在使用 6.0.1 在 Nexus 5 上测试我的 Camera2 实现。该问题似乎与切换闪光灯模式有关。出乎意料的是,更换闪光灯和拍照会导致 AF 未锁定,并且日志中会出现以下内容:

01-13 11:02:53.184   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.217   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.251   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.284   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.318   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.351   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.385   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.419   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.452   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.485   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.519   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.552   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.586   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.619   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.653   214  7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:54.031   214  7174 I mm-camera-sensor: port_sensor_process_aec_est:686 AEC EST DONE
01-13 11:02:54.031   214  7174 I mm-camera-sensor: port_sensor_process_aec_est:686 AEC EST DONE
01-13 11:02:54.031   214  7174 I mm-camera-sensor: port_sensor_process_aec_est:688 regular_led_trigger 1
01-13 11:02:54.648   804  1488 D NetlinkSocketObserver: NeighborEvent{elapsedMs=947757, 10.12.0.254, [000D483417C9], RTM_NEWNEIGH, NUD_PROBE}
01-13 11:02:56.000   197   791 D audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
01-13 11:02:56.001   197   791 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)
01-13 11:02:57.048   214  7192 E mm-camera-sensor: port_sensor_handle_upstream_module_event:1444 Reset previously set LED state!
01-13 11:02:57.048   214  7192 I AEC_PORT: aec_port_proc_downstream_event: Received LED state timeout. Reset LED state!
01-13 11:02:59.918   214  7175 E mm-camera: af_process_parse_stats: Invalid FV data!
01-13 11:02:59.918   214  7175 E mm-camera: af_process: Error processing AF stats!
01-13 11:02:59.952   214  7175 E mm-camera: af_process_parse_stats: Invalid FV data!
01-13 11:02:59.952   214  7175 E mm-camera: af_process: Error processing AF stats!

如果我在不切换闪光灯模式的情况下继续拍照,它可以正常工作(即使闪光灯始终打开)。仅当我切换闪光模式时才会发生这种情况,并且哪种模式处于活动状态似乎并不重要(因此从 FLASH ON 到 FLASH AUTO 或从 FLASH AUTO 到 FLASH OFF 都可能导致此错误)。

这是我更改闪光灯模式的代码:

private void setFlashMode(String mode) {
    if (mode.equals(CAMERA_FLASH_OFF) ) {
        mPreviewRequestBuilder
                .set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
        mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
    }
    else if(mode.equals(CAMERA_FLASH_AUTO)) {
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
        mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
    }
    else if(mode.equals(CAMERA_FLASH_ON)) {
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
        mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
    }
    else if(mode.equals(CAMERA_FLASH_TORCH)) {
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
        mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
    }
    try {
        mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), null,
                mBackgroundHandler);
        if (getOnCameraParametersSetListener() != null) {
            getOnCameraParametersSetListener().onCameraParametersSet();
        }
    } catch (CameraAccessException e) {
        Log.e(TAG,
                ".setFlashMode() - Exception caught while setting the capture session request",
                e);
    }
}

非常感谢任何帮助。

4

1 回答 1

0

看起来问题在于调用时没有传递回调setRepeatingRequest。解决方法是添加原始回调。

于 2016-01-13T11:36:09.393 回答