|
|
|
@ -1042,30 +1042,20 @@ void CameraState::handle_camera_event(void *evdat) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CameraState::update_exposure_score(float desired_ev, int exp_t, int exp_g_idx, float exp_gain) { |
|
|
|
|
float score = std::abs(desired_ev - (exp_t * exp_gain)) * 10; |
|
|
|
|
|
|
|
|
|
if (camera_num==1) { |
|
|
|
|
printf("diff ev score:%.1f \n", score); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Going below recommended gain needs lower penalty to not overexpose
|
|
|
|
|
float score = 1e6; |
|
|
|
|
if (camera_id == CAMERA_ID_AR0231) { |
|
|
|
|
// Cost of ev diff
|
|
|
|
|
score = std::abs(desired_ev - (exp_t * exp_gain)) * 10; |
|
|
|
|
// Cost of absolute gain
|
|
|
|
|
float m = exp_g_idx > analog_gain_rec_idx ? analog_gain_cost_high : analog_gain_cost_low; |
|
|
|
|
|
|
|
|
|
float nt1 = std::abs(exp_g_idx - (int)analog_gain_rec_idx) * m; |
|
|
|
|
if (camera_num==1) { |
|
|
|
|
printf("low gain score:%.1f \n", nt1); |
|
|
|
|
} |
|
|
|
|
score += nt1; |
|
|
|
|
|
|
|
|
|
// Small penalty on changing gain
|
|
|
|
|
float nt2 = ((1 - analog_gain_cost_delta) + analog_gain_cost_delta * (exp_g_idx - analog_gain_min_idx) / (analog_gain_max_idx - analog_gain_min_idx)) * std::abs(exp_g_idx - gain_idx) * (score + 1.0) / 10.0; |
|
|
|
|
if (camera_num==1) { |
|
|
|
|
printf("delta gain score:%.1f \n", nt2); |
|
|
|
|
} |
|
|
|
|
score += nt2; |
|
|
|
|
|
|
|
|
|
if (camera_num==1) { |
|
|
|
|
printf("gain: %.2f, expo: %d, score:%.1f \n", exp_gain, exp_t, score); |
|
|
|
|
score += std::abs(exp_g_idx - (int)analog_gain_rec_idx) * m; |
|
|
|
|
// Cost of changing gain
|
|
|
|
|
score += ((1 - analog_gain_cost_delta) + analog_gain_cost_delta * (exp_g_idx - analog_gain_min_idx) / (analog_gain_max_idx - analog_gain_min_idx)) * std::abs(exp_g_idx - gain_idx) * (score + 1.0) / 10.0; |
|
|
|
|
} else if (camera_id == CAMERA_ID_OX03C10) { |
|
|
|
|
score = std::abs(desired_ev - (exp_t * exp_gain)) * 10; |
|
|
|
|
float m = exp_g_idx > analog_gain_rec_idx ? analog_gain_cost_high : analog_gain_cost_low; |
|
|
|
|
score += std::abs(exp_g_idx - (int)analog_gain_rec_idx) * m; |
|
|
|
|
score += ((1 - analog_gain_cost_delta) + analog_gain_cost_delta * (exp_g_idx - analog_gain_min_idx) / (analog_gain_max_idx - analog_gain_min_idx)) * std::abs(exp_g_idx - gain_idx) * (score + 1.0) / 10.0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (score < best_ev_score) { |
|
|
|
|