欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android?Camera2開啟自動曝光功能

 更新時間:2022年01月04日 14:35:37   作者:胡剛2021  
這篇文章主要為大家詳細(xì)介紹了Android?Camera2開啟自動曝光功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android Camera2開啟自動曝光功能的具體代碼,供大家參考,具體內(nèi)容如下

首先,打開3A的總開關(guān):

CaptureRequest.Builder builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);

獲取支持的 AE FPS Range:

List<int[]> ae_fps_ranges = new ArrayList<>();
for (Range<Integer> r : characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)) {
? ? ae_fps_ranges.add(new int[] {r.getLower(), r.getUpper()});
}
Collections.sort(ae_fps_ranges, new CameraController.RangeSorter());

然后,設(shè)置FPS:

builder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, ae_target_fps_range);

最后,根據(jù) Flash_Mode 設(shè)置 AE_MODE

switch(flash_value) {
? ?case "flash_off":
? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
? ? ? ?builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
? ? ? ?break;
? ?case "flash_auto":
? ? ? ?// note we set this even in fake flash mode (where we manually turn torch on and off to simulate flash) so we
? ? ? ?// can read the FLASH_REQUIRED state to determine if flash is required
? ?/*if( use_fake_precapture || CameraController2.this.want_expo_bracketing )
? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
? ?else*/
? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
? ? ? ?//這里FLASH_MODE可以設(shè)置為任意值,因為AE_MODE優(yōu)先級高
? ? ? ?builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
? ? ? ?break;
? ?case "flash_on":
? ? ? ?// see note above for "flash_auto" for why we set this even fake flash mode - arguably we don't need to know
? ? ? ?// about FLASH_REQUIRED in flash_on mode, but we set it for consistency...
? ?/*if( use_fake_precapture || CameraController2.this.want_expo_bracketing )
? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
? ?else*/
? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
? ? ? ?builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
? ? ? ?break;
? ?case "flash_torch":
? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
? ? ? ?builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
? ? ? ?break;
? ?case "flash_red_eye":
? ? ? ?// not supported for expo bracketing or burst
? ? ? ?if( CameraController2.this.burst_type != BurstType.BURSTTYPE_NONE )
? ? ? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
? ? ? ?else
? ? ? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE);
? ? ? ?builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
? ? ? ?break;
? ?case "flash_frontscreen_auto":
? ?case "flash_frontscreen_on":
? ?case "flash_frontscreen_torch":
? ? ? ?builder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
? ? ? ?builder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
? ? ? ?break;
}

查看每幀的曝光參數(shù):

CameraCaptureSession.CaptureCallback{
?? ?@Override
?? ?public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
?? ??? ?long capture_result_exposure_time = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
?? ??? ?long capture_result_sensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
?? ?}
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論