camerad: optional exposure params overrides (#25616)

* add params override

* speedup

* put in param list

* clean up names

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: e9258cccbe
taco
ZwX1616 3 years ago committed by GitHub
parent 23117b4f15
commit cf84a3ba30
  1. 2
      common/params.cc
  2. 1
      system/camerad/cameras/camera_common.h
  3. 14
      system/camerad/cameras/camera_qcom2.cc
  4. 1
      system/camerad/cameras/camera_qcom2.h

@ -88,6 +88,8 @@ std::unordered_map<std::string, uint32_t> keys = {
{"AthenadPid", PERSISTENT}, {"AthenadPid", PERSISTENT},
{"AthenadUploadQueue", PERSISTENT}, {"AthenadUploadQueue", PERSISTENT},
{"CalibrationParams", PERSISTENT}, {"CalibrationParams", PERSISTENT},
{"CameraDebugExpGain", CLEAR_ON_MANAGER_START},
{"CameraDebugExpTime", CLEAR_ON_MANAGER_START},
{"CarBatteryCapacity", PERSISTENT}, {"CarBatteryCapacity", PERSISTENT},
{"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON},
{"CarParamsCache", CLEAR_ON_MANAGER_START}, {"CarParamsCache", CLEAR_ON_MANAGER_START},

@ -40,6 +40,7 @@ const bool env_disable_wide_road = getenv("DISABLE_WIDE_ROAD") != NULL;
const bool env_disable_driver = getenv("DISABLE_DRIVER") != NULL; const bool env_disable_driver = getenv("DISABLE_DRIVER") != NULL;
const bool env_debug_frames = getenv("DEBUG_FRAMES") != NULL; const bool env_debug_frames = getenv("DEBUG_FRAMES") != NULL;
const bool env_log_raw_frames = getenv("LOG_RAW_FRAMES") != NULL; const bool env_log_raw_frames = getenv("LOG_RAW_FRAMES") != NULL;
const bool env_ctrl_exp_from_params = getenv("CTRL_EXP_FROM_PARAMS") != NULL;
typedef struct CameraInfo { typedef struct CameraInfo {
uint32_t frame_width, frame_height; uint32_t frame_width, frame_height;

@ -1101,7 +1101,18 @@ void CameraState::set_camera_exposure(float grey_frac) {
} else if (enable_dc_gain && target_grey > 0.3) { } else if (enable_dc_gain && target_grey > 0.3) {
enable_dc_gain = false; enable_dc_gain = false;
} }
if (env_ctrl_exp_from_params) {
// Override gain and exposure time
if (buf.cur_frame_data.frame_id % 5 == 0) {
std::string gain_bytes = Params().get("CameraDebugExpGain");
std::string time_bytes = Params().get("CameraDebugExpTime");
gain_idx = std::stoi(gain_bytes);
exposure_time = std::stoi(time_bytes);
}
new_g = gain_idx;
new_t = exposure_time;
enable_dc_gain = false;
} else {
// Simple brute force optimizer to choose sensor parameters // Simple brute force optimizer to choose sensor parameters
// to reach desired EV // to reach desired EV
for (int g = std::max((int)ANALOG_GAIN_MIN_IDX, gain_idx - 1); g <= std::min((int)ANALOG_GAIN_MAX_IDX, gain_idx + 1); g++) { for (int g = std::max((int)ANALOG_GAIN_MIN_IDX, gain_idx - 1); g <= std::min((int)ANALOG_GAIN_MAX_IDX, gain_idx + 1); g++) {
@ -1133,6 +1144,7 @@ void CameraState::set_camera_exposure(float grey_frac) {
best_ev_score = score; best_ev_score = score;
} }
} }
}
exp_lock.lock(); exp_lock.lock();

@ -7,6 +7,7 @@
#include <media/cam_req_mgr.h> #include <media/cam_req_mgr.h>
#include "system/camerad/cameras/camera_common.h" #include "system/camerad/cameras/camera_common.h"
#include "common/params.h"
#include "common/util.h" #include "common/util.h"
#define FRAME_BUF_COUNT 4 #define FRAME_BUF_COUNT 4

Loading…
Cancel
Save