mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 16:23:46 +08:00
fix autobrightness for OX03C10 (#25915)
* fix autobrightness for OX03C10 * fix scaling * use cur ev * oops * bump cereal old-commit-hash: 2384a9ee67fc4480199149657a031510f9f48d14
This commit is contained in:
+1
-1
Submodule cereal updated: e310f4860d...5aa49864bc
+2
-11
@@ -178,15 +178,7 @@ static void update_state(UIState *s) {
|
||||
}
|
||||
}
|
||||
if (sm.updated("wideRoadCameraState")) {
|
||||
auto camera_state = sm["wideRoadCameraState"].getWideRoadCameraState();
|
||||
|
||||
float max_lines = 1618;
|
||||
float max_gain = 10.0;
|
||||
float max_ev = max_lines * max_gain / 6;
|
||||
|
||||
float ev = camera_state.getGain() * float(camera_state.getIntegLines());
|
||||
|
||||
scene.light_sensor = std::clamp<float>(1.0 - (ev / max_ev), 0.0, 1.0);
|
||||
scene.light_sensor = 100.0f - sm["wideRoadCameraState"].getWideRoadCameraState().getExposureValPercent();
|
||||
}
|
||||
scene.started = sm["deviceState"].getDeviceState().getStarted() && scene.ignition;
|
||||
}
|
||||
@@ -286,8 +278,7 @@ void Device::resetInteractiveTimout() {
|
||||
void Device::updateBrightness(const UIState &s) {
|
||||
float clipped_brightness = BACKLIGHT_OFFROAD;
|
||||
if (s.scene.started) {
|
||||
// Scale to 0% to 100%
|
||||
clipped_brightness = 100.0 * s.scene.light_sensor;
|
||||
clipped_brightness = s.scene.light_sensor;
|
||||
|
||||
// CIE 1931 - https://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm
|
||||
if (clipped_brightness <= 8) {
|
||||
|
||||
@@ -162,6 +162,10 @@ void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &fr
|
||||
framed.setLensTruePos(frame_data.lens_true_pos);
|
||||
framed.setProcessingTime(frame_data.processing_time);
|
||||
|
||||
const float ev = c->cur_ev[frame_data.frame_id % 3];
|
||||
const float perc = util::map_val(ev, c->min_ev, c->max_ev, 0.0f, 100.0f);
|
||||
framed.setExposureValPercent(perc);
|
||||
|
||||
if (c->camera_id == CAMERA_ID_AR0231) {
|
||||
framed.setSensor(cereal::FrameData::ImageSensor::AR0321);
|
||||
} else if (c->camera_id == CAMERA_ID_OX03C10) {
|
||||
|
||||
@@ -1078,8 +1078,8 @@ void CameraState::set_camera_exposure(float grey_frac) {
|
||||
|
||||
std::string gain_bytes, time_bytes;
|
||||
if (env_ctrl_exp_from_params) {
|
||||
gain_bytes = Params().get("CameraDebugExpGain");
|
||||
time_bytes = Params().get("CameraDebugExpTime");
|
||||
gain_bytes = Params().get("CameraDebugExpGain");
|
||||
time_bytes = Params().get("CameraDebugExpTime");
|
||||
}
|
||||
|
||||
if (gain_bytes.size() > 0 && time_bytes.size() > 0) {
|
||||
@@ -1150,10 +1150,10 @@ void CameraState::set_camera_exposure(float grey_frac) {
|
||||
if (camera_id == CAMERA_ID_AR0231) {
|
||||
uint16_t analog_gain_reg = 0xFF00 | (new_g << 4) | new_g;
|
||||
struct i2c_random_wr_payload exp_reg_array[] = {
|
||||
{0x3366, analog_gain_reg},
|
||||
{0x3362, (uint16_t)(dc_gain_enabled ? 0x1 : 0x0)},
|
||||
{0x3012, (uint16_t)exposure_time},
|
||||
};
|
||||
{0x3366, analog_gain_reg},
|
||||
{0x3362, (uint16_t)(dc_gain_enabled ? 0x1 : 0x0)},
|
||||
{0x3012, (uint16_t)exposure_time},
|
||||
};
|
||||
sensors_i2c(exp_reg_array, sizeof(exp_reg_array)/sizeof(struct i2c_random_wr_payload), CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG, true);
|
||||
} else if (camera_id == CAMERA_ID_OX03C10) {
|
||||
// t_HCG + t_LCG + t_VS on LPD, t_SPD on SPD
|
||||
@@ -1166,7 +1166,6 @@ void CameraState::set_camera_exposure(float grey_frac) {
|
||||
uint32_t real_gain = ox03c10_analog_gains_reg[new_g];
|
||||
uint32_t min_gain = ox03c10_analog_gains_reg[0];
|
||||
struct i2c_random_wr_payload exp_reg_array[] = {
|
||||
|
||||
{0x3501, hcg_time>>8}, {0x3502, hcg_time&0xFF},
|
||||
{0x3581, lcg_time>>8}, {0x3582, lcg_time&0xFF},
|
||||
{0x3541, spd_time>>8}, {0x3542, spd_time&0xFF},
|
||||
|
||||
Reference in New Issue
Block a user