camerad: fix AE oscillation (#34833)

* flooring is fine

* .

* better solution

---------

Co-authored-by: Comma Device <device@comma.ai>
pull/34838/head
ZwX1616 2 months ago committed by GitHub
parent 58e5b31cca
commit 1c678c910e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      system/camerad/cameras/camera_qcom2.cc

@ -141,7 +141,8 @@ void CameraState::set_camera_exposure(float grey_frac) {
// TODO: Lower latency to 2 frames, by using the histogram outputted by the sensor we can do AE before the debayering is complete // TODO: Lower latency to 2 frames, by using the histogram outputted by the sensor we can do AE before the debayering is complete
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; // Offset idx by one to not get stuck in self loop
const float cur_ev_ = cur_ev[(camera.buf.cur_frame_data.frame_id - 1) % 3] * sensor->ev_scale;
// Scale target grey between min 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), target_grey_minimums[camera.cc.camera_num], 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);

Loading…
Cancel
Save