本讲是android camera专题系列的第37讲,我们介绍android camera2 api专题的拍照打闪实战。
更多资源:
资源 | 描述 |
---|---|
在线课程 | |
知识星球 | 星球名称:深入浅出android camera 星球id: 17296815 |
极客笔记圈 |
geekcamera2 设置不同的flash模式
cameracontroller2#camerasettings#setaemode
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);
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;
}
geekcamera2 拍照打闪流程
- 触发precapture
cameracontroller2#runprecapture
-
等待precapture完成
cameracontroller2#handlestatechange
-
拍照
cameracontroller2#takepictureafterprecapture