|
|
@ -127,6 +127,8 @@ void CameraState::update_exposure_score(float desired_ev, int exp_t, int exp_g_i |
|
|
|
|
|
|
|
|
|
|
|
void CameraState::set_camera_exposure(float grey_frac) { |
|
|
|
void CameraState::set_camera_exposure(float grey_frac) { |
|
|
|
if (!camera.enabled) return; |
|
|
|
if (!camera.enabled) return; |
|
|
|
|
|
|
|
std::vector<double> target_grey_minimums = {0.1, 0.1, 0.125}; // wide, road, driver
|
|
|
|
|
|
|
|
|
|
|
|
const float dt = 0.05; |
|
|
|
const float dt = 0.05; |
|
|
|
|
|
|
|
|
|
|
|
const float ts_grey = 10.0; |
|
|
|
const float ts_grey = 10.0; |
|
|
@ -143,8 +145,8 @@ void CameraState::set_camera_exposure(float grey_frac) { |
|
|
|
const auto &sensor = camera.sensor; |
|
|
|
const auto &sensor = camera.sensor; |
|
|
|
const float cur_ev_ = cur_ev[camera.buf.cur_frame_data.frame_id % 3] * sensor->ev_scale; |
|
|
|
const float cur_ev_ = cur_ev[camera.buf.cur_frame_data.frame_id % 3] * sensor->ev_scale; |
|
|
|
|
|
|
|
|
|
|
|
// Scale target grey between 0.1 and 0.4 depending on lighting conditions
|
|
|
|
// Scale target grey between min and 0.4 depending on lighting conditions
|
|
|
|
float new_target_grey = std::clamp(0.4 - 0.3 * log2(1.0 + sensor->target_grey_factor*cur_ev_) / log2(6000.0), 0.1, 0.4); |
|
|
|
float new_target_grey = std::clamp(0.4 - 0.3 * log2(1.0 + sensor->target_grey_factor*cur_ev_) / log2(6000.0), target_grey_minimums[camera.cc.camera_num], 0.4); |
|
|
|
float target_grey = (1.0 - k_grey) * target_grey_fraction + k_grey * new_target_grey; |
|
|
|
float target_grey = (1.0 - k_grey) * target_grey_fraction + k_grey * new_target_grey; |
|
|
|
|
|
|
|
|
|
|
|
float desired_ev = std::clamp(cur_ev_ / sensor->ev_scale * target_grey / grey_frac, sensor->min_ev, sensor->max_ev); |
|
|
|
float desired_ev = std::clamp(cur_ev_ / sensor->ev_scale * target_grey / grey_frac, sensor->min_ev, sensor->max_ev); |
|
|
|