Android Camera2增加亮度 [英] Android Camera2 increase brightness

查看:960
本文介绍了Android Camera2增加亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用android camera2拍摄连续图像,在这里,当我使用camera2时,与原始相机相比,图像预览亮度非常暗.我看到了,但是该答案中没有类似的要求

I am using android camera2 in my application to take continuous images, Here when I use camera2 getting image preview brightness very dark compare to original camera. I seen this but there is no similar requirement in that answer.

我尝试按照建议的此处:

请注意,仅当android.control.aeMode!= OFF时,此控件才有效.即使android.control.aeLock == true,此控件也会生效.

Note that this control will only be effective if android.control.aeMode != OFF. This control will take effect even when android.control.aeLock == true.

captureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
            captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
            captureRequestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, true);
            captureRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 6);

但是它仍然仅显示预览为深色图像,如下所示.

But it still showing preview as dark image only as shown below.

在这里看到区别:

原始相机:

使用Camera2:

Using Camera2:

在第二个参数中,我需要传递的值是什么?

And what is the value I need to pass as second parameter in:

captureRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 6);

我保留6个是因为按照文档中的建议:

I kept 6 because as suggested in doc's:

例如,如果曝光值(EV)步长为0.333,则"6"表示+2 EV的曝光补偿; -3表示-1 EV的曝光补偿.

For example, if the exposure value (EV) step is 0.333, '6' will mean an exposure compensation of +2 EV; -3 will mean an exposure compensation of -1 EV.

但亮度仍然没有影响.

推荐答案

这里是:

onConfigured()unlockFocus()

captureRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,getRange());

通过使用上面的代码,您将获得更好的预览.但是您捕获的图片将保持原样. 要获得更好的图像,请在 captureStillPicture()

By using the above code you will get the better preview. But your captured picture will remain as it is. To get the better picture as well use the same below code in captureStillPicture()

captureBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, getRange());

getRange是:

    private Range<Integer> getRange() {
    CameraCharacteristics chars = null;
    try {
        chars = mCameraManager.getCameraCharacteristics(mCameraId);
        Range<Integer>[] ranges = chars.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
        Range<Integer> result = null;
        for (Range<Integer> range : ranges) {
            int upper = range.getUpper();
            // 10 - min range upper for my needs
            if (upper >= 10) {
                if (result == null || upper < result.getUpper().intValue()) {
                    result = range;
                }
            }
        }
        if (result == null) {
            result = ranges[0];
        }
        return result;
    } catch (CameraAccessException e) {
        e.printStackTrace();
        return null;
    }
}

这篇关于Android Camera2增加亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆