pull/32112/head
ZwX1616 1 year ago
parent cc9a3fe9eb
commit db41f531ab
  1. 6
      system/camerad/cameras/camera_common.cc
  2. 2
      system/camerad/cameras/camera_common.h
  3. 7
      system/camerad/cameras/camera_qcom2.cc
  4. 9
      system/camerad/sensors/ar0231.cc
  5. 9
      system/camerad/sensors/os04c10.cc
  6. 9
      system/camerad/sensors/ox03c10.cc
  7. 3
      system/camerad/sensors/sensor.h

@ -269,14 +269,14 @@ static void publish_thumbnail(PubMaster *pm, const CameraBuf *b) {
pm->send("thumbnail", msg);
}
float set_exposure_target(const CameraBuf *b, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip) {
float set_exposure_target(const CameraBuf *b, int x_start, int x_len, int x_skip, int y_start, int y_len, int y_skip) {
int lum_med;
uint32_t lum_binning[256] = {0};
const uint8_t *pix_ptr = b->cur_yuv_buf->y;
unsigned int lum_total = 0;
for (int y = y_start; y < y_end; y += y_skip) {
for (int x = x_start; x < x_end; x += x_skip) {
for (int y = y_start; y < y_start + y_len; y += y_skip) {
for (int x = x_start; x < x_start + x_len; x += x_skip) {
uint8_t lum = pix_ptr[(y * b->rgb_width) + x];
lum_binning[lum]++;
lum_total += 1;

@ -75,7 +75,7 @@ typedef void (*process_thread_cb)(MultiCameraState *s, CameraState *c, int cnt);
void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data, CameraState *c);
kj::Array<uint8_t> get_raw_frame_image(const CameraBuf *b);
float set_exposure_target(const CameraBuf *b, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip);
float set_exposure_target(const CameraBuf *b, int x_start, int x_len, int x_skip, int y_start, int y_len, int y_skip);
std::thread start_process_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback);
void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx);

@ -902,7 +902,8 @@ void CameraState::set_camera_exposure(float grey_frac) {
}
static void process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) {
c->set_camera_exposure(set_exposure_target(&c->buf, 96, 1832, 2, 242, 1148, 4));
const auto ae_xywh = c->ci->driver_ae_xywh;
c->set_camera_exposure(set_exposure_target(&c->buf, ae_xywh[0], ae_xywh[2], 2, ae_xywh[1], ae_xywh[3], 4));
MessageBuilder msg;
auto framed = msg.initEvent().initDriverCameraState();
@ -927,9 +928,9 @@ void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) {
c->ci->processRegisters(c, framed);
s->pm->send(c == &s->road_cam ? "roadCameraState" : "wideRoadCameraState", msg);
const auto [x, y, w, h] = (c == &s->wide_road_cam) ? std::tuple(96, 250, 1734, 524) : std::tuple(96, 160, 1734, 986);
const auto ae_xywh = (c == &s->wide_road_cam) ? c->ci->wide_ae_xywh : c->ci->road_ae_xywh;
const int skip = 2;
c->set_camera_exposure(set_exposure_target(b, x, x + w, skip, y, y + h, skip));
c->set_camera_exposure(set_exposure_target(b, ae_xywh[0], ae_xywh[2], skip, ae_xywh[1], ae_xywh[3], skip));
}
void cameras_run(MultiCameraState *s) {

@ -17,6 +17,10 @@ const float sensor_analog_gains_AR0231[] = {
5.0 / 4.0, 6.0 / 4.0, 6.0 / 3.0, 7.0 / 3.0, // 8, 9, 10, 11
7.0 / 2.0, 8.0 / 2.0, 8.0 / 1.0}; // 12, 13, 14, 15 = bypass
const int ar0231_road_ae_xywh[] = {96, 160, 1734, 986};
const int ar0231_wide_ae_xywh[] = {96, 250, 1734, 524};
const int ar0231_driver_ae_xywh[] = {96, 242, 1736, 906};
std::map<uint16_t, std::pair<int, int>> ar0231_build_register_lut(CameraState *c, uint8_t *data) {
// This function builds a lookup table from register address, to a pair of indices in the
// buffer where to read this address. The buffer contains padding bytes,
@ -116,6 +120,11 @@ AR0231::AR0231() {
min_ev = exposure_time_min * sensor_analog_gains[analog_gain_min_idx];
max_ev = exposure_time_max * dc_gain_factor * sensor_analog_gains[analog_gain_max_idx];
target_grey_factor = 1.0;
for (int i = 0; i < 4; i++) {
road_ae_xywh[i] = ar0231_road_ae_xywh[i];
wide_ae_xywh[i] = ar0231_wide_ae_xywh[i];
driver_ae_xywh[i] = ar0231_driver_ae_xywh[i];
}
}
void AR0231::processRegisters(CameraState *c, cereal::FrameData::Builder &framed) const {

@ -16,6 +16,10 @@ const uint32_t os04c10_analog_gains_reg[] = {
0x2E0, 0x300, 0x320, 0x340, 0x380, 0x3C0, 0x400, 0x440, 0x480, 0x4C0, 0x500,
0x540, 0x580, 0x5C0, 0x600, 0x640, 0x680, 0x6C0, 0x700, 0x740, 0x780, 0x7C0};
const int os04c10_road_ae_xywh[] = {44, 50, 2600, 1470};
const int os04c10_wide_ae_xywh[] = {44, 194, 2600, 838};
const int os04c10_driver_ae_xywh[] = {44, 180, 2600, 1340};
} // namespace
OS04C10::OS04C10() {
@ -56,6 +60,11 @@ OS04C10::OS04C10() {
min_ev = (exposure_time_min) * sensor_analog_gains[analog_gain_min_idx];
max_ev = exposure_time_max * dc_gain_factor * sensor_analog_gains[analog_gain_max_idx];
target_grey_factor = 0.01;
for (int i = 0; i < 4; i++) {
road_ae_xywh[i] = os04c10_road_ae_xywh[i];
wide_ae_xywh[i] = os04c10_wide_ae_xywh[i];
driver_ae_xywh[i] = os04c10_driver_ae_xywh[i];
}
}
std::vector<i2c_random_wr_payload> OS04C10::getExposureRegisters(int exposure_time, int new_exp_g, bool dc_gain_enabled) const {

@ -16,6 +16,10 @@ const uint32_t ox03c10_analog_gains_reg[] = {
0x5C0, 0x600, 0x640, 0x680, 0x700, 0x780, 0x800, 0x880, 0x900, 0x980, 0xA00,
0xA80, 0xB00, 0xB80, 0xC00, 0xC80, 0xD00, 0xD80, 0xE00, 0xE80, 0xF00, 0xF80};
const int ox03c10_road_ae_xywh[] = {96, 160, 1734, 986};
const int ox03c10_wide_ae_xywh[] = {96, 250, 1734, 524};
const int ox03c10_driver_ae_xywh[] = {96, 242, 1736, 906};
const uint32_t VS_TIME_MIN_OX03C10 = 1;
const uint32_t VS_TIME_MAX_OX03C10 = 34; // vs < 35
@ -57,6 +61,11 @@ OX03C10::OX03C10() {
min_ev = (exposure_time_min + VS_TIME_MIN_OX03C10) * sensor_analog_gains[analog_gain_min_idx];
max_ev = exposure_time_max * dc_gain_factor * sensor_analog_gains[analog_gain_max_idx];
target_grey_factor = 0.01;
for (int i = 0; i < 4; i++) {
road_ae_xywh[i] = ox03c10_road_ae_xywh[i];
wide_ae_xywh[i] = ox03c10_wide_ae_xywh[i];
driver_ae_xywh[i] = ox03c10_driver_ae_xywh[i];
}
}
std::vector<i2c_random_wr_payload> OX03C10::getExposureRegisters(int exposure_time, int new_exp_g, bool dc_gain_enabled) const {

@ -48,6 +48,9 @@ public:
float target_grey_factor;
float min_ev;
float max_ev;
int road_ae_xywh[4];
int wide_ae_xywh[4];
int driver_ae_xywh[4];
bool data_word;
uint32_t probe_reg_addr;

Loading…
Cancel
Save