mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 02:52:04 +08:00
camerad: cleanup DM exposure and move into camera_qcom2.cc (#24391)
* camerad: cleanup DM exposure and move into camera_qcom2.cc * remove include old-commit-hash: 6e0c25d654771ad13cd276481fc652989f681c2c
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include "selfdrive/camerad/imgproc/utils.h"
|
||||
#include "selfdrive/common/clutil.h"
|
||||
#include "selfdrive/common/modeldata.h"
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
@@ -377,47 +376,6 @@ std::thread start_process_thread(MultiCameraState *cameras, CameraState *cs, pro
|
||||
return std::thread(processing_thread, cameras, cs, callback);
|
||||
}
|
||||
|
||||
static void driver_cam_auto_exposure(CameraState *c, SubMaster &sm) {
|
||||
static const bool is_rhd = Params().getBool("IsRHD");
|
||||
struct ExpRect {int x1, x2, x_skip, y1, y2, y_skip;};
|
||||
const CameraBuf *b = &c->buf;
|
||||
|
||||
int x_offset = 0, y_offset = 0;
|
||||
int frame_width = b->rgb_width, frame_height = b->rgb_height;
|
||||
|
||||
|
||||
ExpRect def_rect;
|
||||
if (Hardware::TICI()) {
|
||||
x_offset = 630, y_offset = 156;
|
||||
frame_width = 668, frame_height = frame_width / 1.33;
|
||||
def_rect = {96, 1832, 2, 242, 1148, 4};
|
||||
} else {
|
||||
def_rect = {is_rhd ? 0 : b->rgb_width * 3 / 5, is_rhd ? b->rgb_width * 2 / 5 : b->rgb_width, 2,
|
||||
b->rgb_height / 3, b->rgb_height, 1};
|
||||
}
|
||||
|
||||
static ExpRect rect = def_rect;
|
||||
|
||||
camera_autoexposure(c, set_exposure_target(b, rect.x1, rect.x2, rect.x_skip, rect.y1, rect.y2, rect.y_skip));
|
||||
}
|
||||
|
||||
void common_process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) {
|
||||
int j = Hardware::TICI() ? 1 : 3;
|
||||
if (cnt % j == 0) {
|
||||
s->sm->update(0);
|
||||
driver_cam_auto_exposure(c, *(s->sm));
|
||||
}
|
||||
MessageBuilder msg;
|
||||
auto framed = msg.initEvent().initDriverCameraState();
|
||||
framed.setFrameType(cereal::FrameData::FrameType::FRONT);
|
||||
fill_frame_data(framed, c->buf.cur_frame_data);
|
||||
if (env_send_driver) {
|
||||
framed.setImage(get_frame_image(&c->buf));
|
||||
}
|
||||
s->pm->send("driverCameraState", msg);
|
||||
}
|
||||
|
||||
|
||||
void camerad_thread() {
|
||||
cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT);
|
||||
#ifdef QCOM2
|
||||
|
||||
@@ -131,7 +131,6 @@ void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &fr
|
||||
kj::Array<uint8_t> get_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);
|
||||
std::thread start_process_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback);
|
||||
void common_process_driver_camera(MultiCameraState *s, CameraState *c, int cnt);
|
||||
|
||||
void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx);
|
||||
void cameras_open(MultiCameraState *s);
|
||||
|
||||
@@ -1114,6 +1114,27 @@ void camera_autoexposure(CameraState *s, float grey_frac) {
|
||||
s->set_camera_exposure(grey_frac);
|
||||
}
|
||||
|
||||
static void driver_cam_auto_exposure(CameraState *c, SubMaster &sm) {
|
||||
struct ExpRect {int x1, x2, x_skip, y1, y2, y_skip;};
|
||||
const CameraBuf *b = &c->buf;
|
||||
static ExpRect rect = {96, 1832, 2, 242, 1148, 4};
|
||||
camera_autoexposure(c, set_exposure_target(b, rect.x1, rect.x2, rect.x_skip, rect.y1, rect.y2, rect.y_skip));
|
||||
}
|
||||
|
||||
static void process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) {
|
||||
s->sm->update(0);
|
||||
driver_cam_auto_exposure(c, *(s->sm));
|
||||
|
||||
MessageBuilder msg;
|
||||
auto framed = msg.initEvent().initDriverCameraState();
|
||||
framed.setFrameType(cereal::FrameData::FrameType::FRONT);
|
||||
fill_frame_data(framed, c->buf.cur_frame_data);
|
||||
if (env_send_driver) {
|
||||
framed.setImage(get_frame_image(&c->buf));
|
||||
}
|
||||
s->pm->send("driverCameraState", msg);
|
||||
}
|
||||
|
||||
// called by processing_thread
|
||||
void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) {
|
||||
const CameraBuf *b = &c->buf;
|
||||
@@ -1139,7 +1160,7 @@ void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) {
|
||||
void cameras_run(MultiCameraState *s) {
|
||||
LOG("-- Starting threads");
|
||||
std::vector<std::thread> threads;
|
||||
if (s->driver_cam.enabled) threads.push_back(start_process_thread(s, &s->driver_cam, common_process_driver_camera));
|
||||
if (s->driver_cam.enabled) threads.push_back(start_process_thread(s, &s->driver_cam, process_driver_camera));
|
||||
if (s->road_cam.enabled) threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera));
|
||||
if (s->wide_road_cam.enabled) threads.push_back(start_process_thread(s, &s->wide_road_cam, process_road_camera));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user