From 1c678c910e5c25f55cecadcf0991b242a7e32358 Mon Sep 17 00:00:00 2001 From: ZwX1616 Date: Mon, 10 Mar 2025 16:01:03 -0700 Subject: [PATCH] camerad: fix AE oscillation (#34833) * flooring is fine * . * better solution --------- Co-authored-by: Comma Device --- system/camerad/cameras/camera_qcom2.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/camerad/cameras/camera_qcom2.cc b/system/camerad/cameras/camera_qcom2.cc index f050070d63..18a42f05d8 100644 --- a/system/camerad/cameras/camera_qcom2.cc +++ b/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 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 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);