it's not really rgb

pull/33584/head
Adeeb Shihadeh 11 months ago
parent b733b875f8
commit 5378e63812
  1. 24
      system/camerad/cameras/camera_common.cc
  2. 2
      system/camerad/cameras/camera_common.h
  3. 8
      system/camerad/cameras/camera_qcom2.cc
  4. 6
      system/camerad/test/test_ae_gray.cc

@ -26,7 +26,7 @@ public:
"-DRGB_WIDTH=%d -DRGB_HEIGHT=%d -DYUV_STRIDE=%d -DUV_OFFSET=%d " "-DRGB_WIDTH=%d -DRGB_HEIGHT=%d -DYUV_STRIDE=%d -DUV_OFFSET=%d "
"-DSENSOR_ID=%hu -DHDR_OFFSET=%d -DVIGNETTING=%d ", "-DSENSOR_ID=%hu -DHDR_OFFSET=%d -DVIGNETTING=%d ",
sensor->frame_width, sensor->frame_height, sensor->hdr_offset > 0 ? sensor->frame_stride * 2 : sensor->frame_stride, sensor->frame_offset, sensor->frame_width, sensor->frame_height, sensor->hdr_offset > 0 ? sensor->frame_stride * 2 : sensor->frame_stride, sensor->frame_offset,
b->rgb_width, b->rgb_height, buf_width, uv_offset, b->out_img_width, b->out_img_height, buf_width, uv_offset,
static_cast<unsigned short>(sensor->image_sensor), sensor->hdr_offset, s->cc.camera_num == 1); static_cast<unsigned short>(sensor->image_sensor), sensor->hdr_offset, s->cc.camera_num == 1);
const char *cl_file = "cameras/process_raw.cl"; const char *cl_file = "cameras/process_raw.cl";
cl_program prg_imgproc = cl_program_from_file(context, device_id, cl_file, args); cl_program prg_imgproc = cl_program_from_file(context, device_id, cl_file, args);
@ -79,20 +79,20 @@ void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s,
} }
LOGD("allocated %d CL buffers", frame_buf_count); LOGD("allocated %d CL buffers", frame_buf_count);
rgb_width = sensor->frame_width; out_img_width = sensor->frame_width;
rgb_height = sensor->hdr_offset > 0 ? (sensor->frame_height - sensor->hdr_offset) / 2 : sensor->frame_height; out_img_height = sensor->hdr_offset > 0 ? (sensor->frame_height - sensor->hdr_offset) / 2 : sensor->frame_height;
int nv12_width = VENUS_Y_STRIDE(COLOR_FMT_NV12, rgb_width); int nv12_width = VENUS_Y_STRIDE(COLOR_FMT_NV12, out_img_width);
int nv12_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12, rgb_height); int nv12_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12, out_img_height);
assert(nv12_width == VENUS_UV_STRIDE(COLOR_FMT_NV12, rgb_width)); assert(nv12_width == VENUS_UV_STRIDE(COLOR_FMT_NV12, out_img_width));
assert(nv12_height/2 == VENUS_UV_SCANLINES(COLOR_FMT_NV12, rgb_height)); assert(nv12_height/2 == VENUS_UV_SCANLINES(COLOR_FMT_NV12, out_img_height));
size_t nv12_uv_offset = nv12_width * nv12_height; size_t nv12_uv_offset = nv12_width * nv12_height;
// the encoder HW tells us the size it wants after setting it up. // the encoder HW tells us the size it wants after setting it up.
// TODO: VENUS_BUFFER_SIZE should give the size, but it's too small. dependent on encoder settings? // TODO: VENUS_BUFFER_SIZE should give the size, but it's too small. dependent on encoder settings?
size_t nv12_size = (rgb_width <= 1344 ? 2900 : 2346)*nv12_width; size_t nv12_size = (out_img_width <= 1344 ? 2900 : 2346)*nv12_width;
vipc_server->create_buffers_with_sizes(stream_type, YUV_BUFFER_COUNT, false, rgb_width, rgb_height, nv12_size, nv12_width, nv12_uv_offset); vipc_server->create_buffers_with_sizes(stream_type, YUV_BUFFER_COUNT, false, out_img_width, out_img_height, nv12_size, nv12_width, nv12_uv_offset);
LOGD("created %d YUV vipc buffers with size %dx%d", YUV_BUFFER_COUNT, nv12_width, nv12_height); LOGD("created %d YUV vipc buffers with size %dx%d", YUV_BUFFER_COUNT, nv12_width, nv12_height);
imgproc = new ImgProc(device_id, context, this, s, nv12_width, nv12_uv_offset); imgproc = new ImgProc(device_id, context, this, s, nv12_width, nv12_uv_offset);
@ -118,7 +118,7 @@ bool CameraBuf::acquire() {
cur_camera_buf = &camera_bufs[cur_buf_idx]; cur_camera_buf = &camera_bufs[cur_buf_idx];
double start_time = millis_since_boot(); double start_time = millis_since_boot();
imgproc->runKernel(camera_bufs[cur_buf_idx].buf_cl, cur_yuv_buf->buf_cl, rgb_width, rgb_height, cur_frame_data.integ_lines); imgproc->runKernel(camera_bufs[cur_buf_idx].buf_cl, cur_yuv_buf->buf_cl, out_img_width, out_img_height, cur_frame_data.integ_lines);
cur_frame_data.processing_time = (millis_since_boot() - start_time) / 1000.0; cur_frame_data.processing_time = (millis_since_boot() - start_time) / 1000.0;
VisionIpcBufExtra extra = { VisionIpcBufExtra extra = {
@ -244,7 +244,7 @@ static kj::Array<capnp::byte> yuv420_to_jpeg(const CameraBuf *b, int thumbnail_w
} }
void publish_thumbnail(PubMaster *pm, const CameraBuf *b) { void publish_thumbnail(PubMaster *pm, const CameraBuf *b) {
auto thumbnail = yuv420_to_jpeg(b, b->rgb_width / 4, b->rgb_height / 4); auto thumbnail = yuv420_to_jpeg(b, b->out_img_width / 4, b->out_img_height / 4);
if (thumbnail.size() == 0) return; if (thumbnail.size() == 0) return;
MessageBuilder msg; MessageBuilder msg;
@ -264,7 +264,7 @@ float set_exposure_target(const CameraBuf *b, Rect ae_xywh, int x_skip, int y_sk
unsigned int lum_total = 0; unsigned int lum_total = 0;
for (int y = ae_xywh.y; y < ae_xywh.y + ae_xywh.h; y += y_skip) { for (int y = ae_xywh.y; y < ae_xywh.y + ae_xywh.h; y += y_skip) {
for (int x = ae_xywh.x; x < ae_xywh.x + ae_xywh.w; x += x_skip) { for (int x = ae_xywh.x; x < ae_xywh.x + ae_xywh.w; x += x_skip) {
uint8_t lum = pix_ptr[(y * b->rgb_width) + x]; uint8_t lum = pix_ptr[(y * b->out_img_width) + x];
lum_binning[lum]++; lum_binning[lum]++;
lum_total += 1; lum_total += 1;
} }

@ -58,7 +58,7 @@ public:
VisionBuf *cur_camera_buf; VisionBuf *cur_camera_buf;
std::unique_ptr<VisionBuf[]> camera_bufs; std::unique_ptr<VisionBuf[]> camera_bufs;
std::unique_ptr<FrameMetadata[]> camera_bufs_metadata; std::unique_ptr<FrameMetadata[]> camera_bufs_metadata;
int rgb_width, rgb_height; int out_img_width, out_img_height;
CameraBuf() = default; CameraBuf() = default;
~CameraBuf(); ~CameraBuf();

@ -429,10 +429,10 @@ void CameraState::set_exposure_rect() {
float fl_ref = ae_target.second; float fl_ref = ae_target.second;
ae_xywh = (Rect){ ae_xywh = (Rect){
std::max(0, buf.rgb_width / 2 - (int)(fl_pix / fl_ref * xywh_ref.w / 2)), std::max(0, buf.out_img_width / 2 - (int)(fl_pix / fl_ref * xywh_ref.w / 2)),
std::max(0, buf.rgb_height / 2 - (int)(fl_pix / fl_ref * (h_ref / 2 - xywh_ref.y))), std::max(0, buf.out_img_height / 2 - (int)(fl_pix / fl_ref * (h_ref / 2 - xywh_ref.y))),
std::min((int)(fl_pix / fl_ref * xywh_ref.w), buf.rgb_width / 2 + (int)(fl_pix / fl_ref * xywh_ref.w / 2)), std::min((int)(fl_pix / fl_ref * xywh_ref.w), buf.out_img_width / 2 + (int)(fl_pix / fl_ref * xywh_ref.w / 2)),
std::min((int)(fl_pix / fl_ref * xywh_ref.h), buf.rgb_height / 2 + (int)(fl_pix / fl_ref * (h_ref / 2 - xywh_ref.y))) std::min((int)(fl_pix / fl_ref * xywh_ref.h), buf.out_img_height / 2 + (int)(fl_pix / fl_ref * (h_ref / 2 - xywh_ref.y)))
}; };
} }

@ -34,11 +34,11 @@ TEST_CASE("camera.test_set_exposure_target") {
uint8_t * fb_y = new uint8_t[W*H]; uint8_t * fb_y = new uint8_t[W*H];
vb.y = fb_y; vb.y = fb_y;
cb.cur_yuv_buf = &vb; cb.cur_yuv_buf = &vb;
cb.rgb_width = W; cb.out_img_width = W;
cb.rgb_height = H; cb.out_img_height = H;
Rect rect = {0, 0, W-1, H-1}; Rect rect = {0, 0, W-1, H-1};
printf("AE test patterns %dx%d\n", cb.rgb_width, cb.rgb_height); printf("AE test patterns %dx%d\n", cb.out_img_width, cb.out_img_height);
// mix of 5 tones // mix of 5 tones
uint8_t l[5] = {0, 24, 48, 96, 235}; // 235 is yuv max uint8_t l[5] = {0, 24, 48, 96, 235}; // 235 is yuv max

Loading…
Cancel
Save