create_thumbnail in camera_common (#19553)

albatross
Dean Lee 2021-01-09 06:31:21 +08:00 committed by GitHub
parent 621dcf8aa1
commit cefdca2fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 17 deletions

View File

@ -243,9 +243,7 @@ void fill_frame_image(cereal::FrameData::Builder &framed, uint8_t *dat, int w, i
}
}
void create_thumbnail(MultiCameraState *s, CameraState *c, uint8_t *bgr_ptr) {
const CameraBuf *b = &c->buf;
static void create_thumbnail(MultiCameraState *s, const CameraBuf *b) {
uint8_t* thumbnail_buffer = NULL;
unsigned long thumbnail_len = 0;
@ -273,6 +271,7 @@ void create_thumbnail(MultiCameraState *s, CameraState *c, uint8_t *bgr_ptr) {
#endif
JSAMPROW row_pointer[1];
const uint8_t *bgr_ptr = (const uint8_t *)b->cur_rgb_buf->addr;
for (int ii = 0; ii < b->rgb_height/4; ii+=1) {
for (int j = 0; j < b->rgb_width*3; j+=12) {
for (int k = 0; k < 3; k++) {
@ -355,6 +354,10 @@ void *processing_thread(MultiCameraState *cameras, const char *tname,
callback(cameras, cs, cnt);
if (cs == &(cameras->rear) && cnt % 100 == 3) {
// this takes 10ms???
create_thumbnail(cameras, &(cs->buf));
}
cs->buf.release();
}
return NULL;

View File

@ -139,7 +139,6 @@ typedef void (*process_thread_cb)(MultiCameraState *s, CameraState *c, int cnt);
void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data, uint32_t cnt);
void fill_frame_image(cereal::FrameData::Builder &framed, uint8_t *dat, int w, int h, int stride);
void create_thumbnail(MultiCameraState *s, CameraState *c, uint8_t *bgr_ptr);
void set_exposure_target(CameraState *c, const uint8_t *pix_ptr, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip);
std::thread start_process_thread(MultiCameraState *cameras, const char *tname,
CameraState *cs, process_thread_cb callback);

View File

@ -111,10 +111,7 @@ void cameras_close(MultiCameraState *s) {
// called by processing_thread
void camera_process_rear(MultiCameraState *s, CameraState *c, int cnt) {
if (cnt % 100 == 3) {
const CameraBuf *b = &c->buf;
create_thumbnail(s, c, (uint8_t*)b->cur_rgb_buf->addr);
}
// empty
}
void cameras_run(MultiCameraState *s) {

View File

@ -1674,10 +1674,6 @@ void camera_process_frame(MultiCameraState *s, CameraState *c, int cnt) {
framed.setTransform(b->yuv_transform.v);
s->pm->send("frame", msg);
if (cnt % 100 == 3) {
create_thumbnail(s, c, (uint8_t *)b->cur_rgb_buf->addr);
}
if (cnt % 3 == 0) {
const int x = 290, y = 322, width = 560, height = 314;
const int skip = 1;

View File

@ -1115,11 +1115,6 @@ void camera_process_frame(MultiCameraState *s, CameraState *c, int cnt) {
}
s->pm->send(c == &s->rear ? "frame" : "wideFrame", msg);
if (c == &s->rear && cnt % 100 == 3) {
// this takes 10ms???
create_thumbnail(s, c, (uint8_t*)b->cur_rgb_buf->addr);
}
if (cnt % 3 == 0) {
int exposure_x;
int exposure_y;