输出图像像素均为0x008700

时间:2019-05-08 23:20:14

标签: android-camera2

我编写了一个使用camera2 API捕获图像的应用程序。通常,一切正常,但是捕获的图像的所有像素偶尔都具有值0x008700。 onCaptureFailed(),onCaptureBufferLost(),onCaptureSequenceAborted()或onError()回调均不会被调用。只是一个绿色的缓冲区。

作为一种变通方法,我检查了生成的位图,如果前10个像素为0x008700,请用户重新捕获图像。通常有效。 我在下面显示了请求生成器代码。

任何线索将不胜感激!

requestBuilder = camera2Device.createCaptureRequest(CameraDevice.TEMPLATE_MANUAL);
checkHardwareSupport(characteristics); //throws if NG
float          availableApertures[]    = getAvailableApertures(characteristics);
float          availableFocalLengths[] = getAvailableAttributeValues(characteristics,
                                                                                                                                         CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS);
Range<Long>    availableShutterTimes   = getAvailableShutterSpeedRange(characteristics);
Range<Integer> availableIsoRange       = getAvailableISORange(characteristics);

exposureSettings = computeExposureSetting(exposureSettings, //gets populated and  returned.
                                                                                    availableApertures,
                                                                                    availableShutterTimes,
                                                                                    availableIsoRange);
requestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CONTROL_CAPTURE_INTENT_STILL_CAPTURE);//CONTROL_CAPTURE_INTENT_MANUAL);manual causes  Error 4 !!!!
requestBuilder.set(CaptureRequest.CONTROL_MODE,CONTROL_MODE_OFF );
requestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF);
requestBuilder.set(CaptureRequest.LENS_FOCAL_LENGTH, availableFocalLengths[0]);
requestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) (exposureSettings.shutterSpeed * nanosPerSecond));
requestBuilder.set(CaptureRequest.LENS_APERTURE, exposureSettings.fStop);
requestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Math.round(exposureSettings.iso));
requestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE,0.0f);//infinity
requestBuilder.addTarget(imageCaptureSurface);
imageCaptureRequest = requestBuilder.build();

0 个答案:

没有答案