图1
如上图1中所看到的,开启 HDR 后,暗处的树和墙壁都获得正确的曝光,都能看得清楚。
图2
图3
如上图3中开启了 HDR, 左上角及楼道里的场景能拍得更亮一些。图片均来自网络!
事实上现方法是通过设三组 ev 值来对当前拍摄的景物曝光,一张照片是使用当前測光从而算出来的正常情况下的ev值曝光,另外两张则分别使用其0.5倍的ev值和2倍的ev值进行曝光。终于对三张照片按某种算法进行合成,暗处的景物使用2倍ev曝光的局部照片,而亮处的物体则使用0.5倍ev曝光的局部照片。这样就能使得整个照片的场景都不致于太亮或太暗。
BOOL OV5645MIPI_set_param_exposure_for_HDR(UINT16 para) { kal_uint32 totalGain = 0, exposureTime = 0; OV5645MIPISENSORDB("[OV5645MIPI]enter OV5645MIPI_set_param_exposure_for_HDR function:\n "); OV5645MIPISENSORDB("[OV5645MIPI]enter para=%d,manualAEStart%d\n",para,OV5645MIPISensor.manualAEStart); if (0 == OV5645MIPISensor.manualAEStart) { OV5645MIPI_set_AE_mode(KAL_FALSE);//Manual AE enable spin_lock(&ov5645mipi_drv_lock); OV5645MIPISensor.manualAEStart = 1; spin_unlock(&ov5645mipi_drv_lock); } totalGain = OV5645MIPISensor.currentAxDGain; exposureTime = OV5645MIPISensor.currentExposureTime; switch (para) { case AE_EV_COMP_20: //+2 EV case AE_EV_COMP_10: // +1 EV totalGain = totalGain<<1; exposureTime = exposureTime<<1; OV5645MIPISENSORDB("[4EC] HDR AE_EV_COMP_20\n"); break; case AE_EV_COMP_00: // +0 EV OV5645MIPISENSORDB("[4EC] HDR AE_EV_COMP_00\n"); break; case AE_EV_COMP_n10: // -1 EV case AE_EV_COMP_n20: // -2 EV totalGain = totalGain >> 1; exposureTime = exposureTime >> 1; OV5645MIPISENSORDB("[4EC] HDR AE_EV_COMP_n20\n"); break; default: break;//return FALSE; } totalGain = (totalGain > OV5645MIPI_MAX_AXD_GAIN) ? OV5645MIPI_MAX_AXD_GAIN : totalGain; //exposureTime = (exposureTime > OV5645MIPI_MAX_EXPOSURE_TIME) ? OV5645MIPI_MAX_EXPOSURE_TIME : exposureTime; OV5645MIPIWriteSensorGain(totalGain); OV5645MIPIWriteShutter(exposureTime); OV5645MIPISENSORDB("[OV5645MIPI]exit OV5645MIPI_set_param_exposure_for_HDR function:\n "); return TRUE; }