我正在为一个研究项目编写一个数据收集应用程序,它使用新的Camera2 API静静地拍照,而不显示预览。问题是所有的照片都严重曝光不足,通常是全黑的,房间特征的轮廓微弱。这尤其是一个问题,因为我的用例涉及拍摄室内环境的照片。这是我的捕获代码:
private void setupCamera(){
assert mCamera != null;
Log.d("Camera Status", "setting up...");
ArrayList<Surface> s = new ArrayList<Surface>();
assert mSurface != null;
try {
CaptureRequest.Builder builder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
builder.addTarget(mSurface);
builder.set(CaptureRequest.CONTROL_AE_LOCK, false);
builder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CameraMetadata.CONTROL_AE_PRECAPTURE_TRIGGER_START);
builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START);
builder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO);
builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
builder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 6);
final CaptureRequest request = builder.build();
s.add(mSurface);
Log.d("Camera Status", "Creating Capture Session...");
mCamera.createCaptureSession(s, new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(CameraCaptureSession session) {
try {
Log.d("AE PRECAPTURE TRIGGER", request.get(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER) + "");
session.capture(request, new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
super.onCaptureCompleted(session, request, result);
context.updateStatus("Capture Successful");
Log.d("Capture Result", "Success");
mCamera.close();
}
@Override
public void onCaptureFailed(CameraCaptureSession session, CaptureRequest request, CaptureFailure failure) {
super.onCaptureFailed(session, request, failure);
Log.d("Capture Result", "Failure");
context.updateStatus("Capture Failed");
}
}, context.handler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
@Override
public void onConfigureFailed(CameraCaptureSession session) {
}
}, context.handler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
任何帮助将不胜感激!感谢