gpt4 book ai didi

android - 在 android camera2API 中控制传感器 ISO 和曝光时间

转载 作者:搜寻专家 更新时间:2023-11-01 08:34:13 28 4
gpt4 key购买 nike

我正在尝试在手动相机控制中添加新的曝光值和 ISO 值。我正在使用 Camera2Basic 示例。我现在面临的问题是我是 Android 的新手。我尝试查看 L-Camera,但它在 Scala 中,这让我更加困惑。

我尝试了以下更改,但图像预览没有更新。

 private void createCameraPreviewSession() {
try {
SurfaceTexture texture = mTextureView.getSurfaceTexture();
assert texture != null;

// We configure the size of default buffer to be the size of camera preview we want.
texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());

// This is the output Surface we need to start preview.
Surface surface = new Surface(texture);

// We set up a CaptureRequest.Builder with the output Surface.
mPreviewRequestBuilder
= mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mPreviewRequestBuilder.addTarget(surface);

// Here, we create a CameraCaptureSession for camera preview.
mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()),
new CameraCaptureSession.StateCallback() {

@Override
public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
// The camera is already closed
if (null == mCameraDevice) {
return;
}

// When the session is ready, we start displaying the preview.
mCaptureSession = cameraCaptureSession;
try {
// Auto focus should be continuous for camera preview.
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
CaptureRequest.CONTROL_AE_MODE_OFF);

mPreviewRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME,Long.valueOf("100000"));
mPreviewRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY,1600);

// Flash is automatically enabled when necessary.
setAutoFlash(mPreviewRequestBuilder);

// Finally, we start displaying the camera preview.
mPreviewRequest = mPreviewRequestBuilder.build();
mCaptureSession.setRepeatingRequest(mPreviewRequest,
mCaptureCallback, mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}

@Override
public void onConfigureFailed(
@NonNull CameraCaptureSession cameraCaptureSession) {
showToast("Failed");
}
}, null
);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}

最佳答案

首先,您必须将模板更改为 TEMPLATE_STILL_CAPTURETEMPLATE_MANUAL 才能在预览中看到值的变化。另外,请记住将您的 CONTROL_AE_MODE 和“CONTROL_MODE”设置为 OFF。

This control is only effective if android.control.aeMode or android.control.mode is set to OFF; otherwise the auto-exposure algorithm will override this value.

来自 Android Developer

其次,设置您的值(value)观:

builder.set(CaptureRequest.SENSOR_SENSITIVITY, isoValue);
builder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, exposureTimeValueInMilliseconds);

最后,在所有更改之后不要忘记使用 CaptureSession.setRepeatingRequest

更新您的预览

希望对您有所帮助!

关于android - 在 android camera2API 中控制传感器 ISO 和曝光时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38058843/

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