Skip to content

Commit

Permalink
stil use image width for now
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Feb 21, 2025
1 parent 9d9ea76 commit 15eca7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions system/camerad/cameras/camera_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ kj::Array<uint8_t> get_raw_frame_image(const CameraBuf *b) {
return kj::mv(frame_image);
}

float calculate_exposure_value(const CameraBuf *b, Rect ae_xywh, int x_skip, int y_skip) {
int lum_med;
float calculate_exposure_value(const CameraBuf *b, const Rect &ae_xywh, int x_skip, int y_skip) {
uint32_t lum_binning[256] = {0};
const uint8_t *pix_ptr = b->cur_yuv_buf->y;
const int stride = b->out_img_width;
const int bottom = ae_xywh.y + ae_xywh.h;
const int right = ae_xywh.x + ae_xywh.w;
unsigned int lum_total = 0;

for (int y = ae_xywh.y; y < bottom; y += y_skip) {
const uint8_t *row_ptr = &pix_ptr[y * b->out_img_width];
const uint8_t *row_ptr = &pix_ptr[y * stride];
for (int x = ae_xywh.x; x < right; x += x_skip) {
uint8_t lum = row_ptr[x];
lum_binning[lum]++;
Expand All @@ -111,6 +111,7 @@ float calculate_exposure_value(const CameraBuf *b, Rect ae_xywh, int x_skip, int

// Find mean lumimance value
unsigned int lum_cur = 0;
int lum_med;
for (lum_med = 255; lum_med >= 0; lum_med--) {
lum_cur += lum_binning[lum_med];

Expand Down
2 changes: 1 addition & 1 deletion system/camerad/cameras/camera_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ class CameraBuf {

void camerad_thread();
kj::Array<uint8_t> get_raw_frame_image(const CameraBuf *b);
float calculate_exposure_value(const CameraBuf *b, Rect ae_xywh, int x_skip, int y_skip);
float calculate_exposure_value(const CameraBuf *b, const Rect &ae_xywh, int x_skip, int y_skip);
int open_v4l_by_name_and_index(const char name[], int index = 0, int flags = O_RDWR | O_NONBLOCK);

0 comments on commit 15eca7a

Please sign in to comment.