更改相机 2 的相机设置 API android
Change Camera Settings for the Camera2 API android
我正在使用 android-camera2-secret-picture-taker
并获取黑暗且无法更改捕获生成器中的白平衡的图像。
以下是我对 capturebuilder 所做的更改:
/**相机设置*/
// captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation());
/**HDR*/
captureBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_HDR);
/**Settings for Flash*/
captureBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
/**for White Balance */
captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_AUTO));
//for incandescent
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_INCANDESCENT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_INCANDESCENT));
// captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, CameraCapabilities.colorTemperature(Integer.parseInt(awbMode)));
//for daylight
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_DAYLIGHT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_DAYLIGHT));
}
//for fluorescent
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_FLUORESCENT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_FLUORESCENT));}
//for cloudy
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_CLOUDY_DAYLIGHT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_CLOUDY_DAYLIGHT));
/**For ISO*/
captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
CameraCharacteristics mCameraCharacteristics = characteristics;
List keys_list = characteristics.getKeys();
Range<Integer> range2 = characteristics.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
int iso = ((200 * (200 - 100)) / 100 + 100);
if (range2 != null) {
int max1 = range2.getUpper();//10000
int min1 = range2.getLower();//100
iso = ((max1 * (max1 - min1)) / 100 + min1);
}
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, iso);
我无法更改亮度和除 FlashMode 之外的其他设置。
我相信您正在寻找 "Auto Exposure" 因为您在谈论亮度。因此,我建议您使用:
captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 4);
// play around with the "4" which is the amount of brightness you want compensate by.
我正在使用 android-camera2-secret-picture-taker 并获取黑暗且无法更改捕获生成器中的白平衡的图像。 以下是我对 capturebuilder 所做的更改:
/**相机设置*/ // captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO); captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation());
/**HDR*/
captureBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_HDR);
/**Settings for Flash*/
captureBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
/**for White Balance */
captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_AUTO));
//for incandescent
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_INCANDESCENT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_INCANDESCENT));
// captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, CameraCapabilities.colorTemperature(Integer.parseInt(awbMode)));
//for daylight
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_DAYLIGHT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_DAYLIGHT));
}
//for fluorescent
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_FLUORESCENT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_FLUORESCENT));}
//for cloudy
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_CLOUDY_DAYLIGHT);
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_CLOUDY_DAYLIGHT));
/**For ISO*/
captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
CameraCharacteristics mCameraCharacteristics = characteristics;
List keys_list = characteristics.getKeys();
Range<Integer> range2 = characteristics.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
int iso = ((200 * (200 - 100)) / 100 + 100);
if (range2 != null) {
int max1 = range2.getUpper();//10000
int min1 = range2.getLower();//100
iso = ((max1 * (max1 - min1)) / 100 + min1);
}
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, iso);
我无法更改亮度和除 FlashMode 之外的其他设置。
我相信您正在寻找 "Auto Exposure" 因为您在谈论亮度。因此,我建议您使用:
captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 4);
// play around with the "4" which is the amount of brightness you want compensate by.