我正在使用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);
}
}
非常感谢任何帮助。
答案 0 :(得分:0)
看起来问题是在调用setRepeatingRequest
时没有传递回调。修复是添加原始回调。