mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-24 23:42:05 +08:00
camerad: cleanup main.cc (#23593)
* cleanup main.cc * fix ae_gray_test build errors
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
#ifdef QCOM
|
||||
#include "CL/cl_ext_qcom.h"
|
||||
#include "selfdrive/camerad/cameras/camera_qcom.h"
|
||||
#elif QCOM2
|
||||
#include "selfdrive/camerad/cameras/camera_qcom2.h"
|
||||
@@ -28,6 +29,8 @@
|
||||
#include "selfdrive/camerad/cameras/camera_replay.h"
|
||||
#endif
|
||||
|
||||
ExitHandler do_exit;
|
||||
|
||||
class Debayer {
|
||||
public:
|
||||
Debayer(cl_device_id device_id, cl_context context, const CameraBuf *b, const CameraState *s) {
|
||||
@@ -339,8 +342,6 @@ float set_exposure_target(const CameraBuf *b, int x_start, int x_end, int x_skip
|
||||
return lum_med / 256.0;
|
||||
}
|
||||
|
||||
extern ExitHandler do_exit;
|
||||
|
||||
void *processing_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback) {
|
||||
const char *thread_name = nullptr;
|
||||
if (cs == &cameras->road_cam) {
|
||||
@@ -422,3 +423,27 @@ void common_process_driver_camera(MultiCameraState *s, CameraState *c, int cnt)
|
||||
}
|
||||
s->pm->send("driverCameraState", msg);
|
||||
}
|
||||
|
||||
|
||||
void camerad_thread() {
|
||||
cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT);
|
||||
// TODO: do this for QCOM2 too
|
||||
#if defined(QCOM)
|
||||
const cl_context_properties props[] = {CL_CONTEXT_PRIORITY_HINT_QCOM, CL_PRIORITY_HINT_HIGH_QCOM, 0};
|
||||
cl_context context = CL_CHECK_ERR(clCreateContext(props, 1, &device_id, NULL, NULL, &err));
|
||||
#else
|
||||
cl_context context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err));
|
||||
#endif
|
||||
|
||||
MultiCameraState cameras = {};
|
||||
VisionIpcServer vipc_server("camerad", device_id, context);
|
||||
|
||||
cameras_init(&vipc_server, &cameras, device_id, context);
|
||||
cameras_open(&cameras);
|
||||
|
||||
vipc_server.start_listener();
|
||||
|
||||
cameras_run(&cameras);
|
||||
|
||||
CL_CHECK(clReleaseContext(context));
|
||||
}
|
||||
|
||||
@@ -129,3 +129,4 @@ void cameras_open(MultiCameraState *s);
|
||||
void cameras_run(MultiCameraState *s);
|
||||
void cameras_close(MultiCameraState *s);
|
||||
void camera_autoexposure(CameraState *s, float grey_frac);
|
||||
void camerad_thread();
|
||||
|
||||
@@ -1,48 +1,11 @@
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include "selfdrive/camerad/cameras/camera_common.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <thread>
|
||||
|
||||
#include "libyuv.h"
|
||||
|
||||
#include "cereal/visionipc/visionipc_server.h"
|
||||
#include "selfdrive/common/clutil.h"
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
#ifdef QCOM
|
||||
#include "selfdrive/camerad/cameras/camera_qcom.h"
|
||||
#elif QCOM2
|
||||
#include "selfdrive/camerad/cameras/camera_qcom2.h"
|
||||
#elif WEBCAM
|
||||
#include "selfdrive/camerad/cameras/camera_webcam.h"
|
||||
#else
|
||||
#include "selfdrive/camerad/cameras/camera_replay.h"
|
||||
#endif
|
||||
|
||||
ExitHandler do_exit;
|
||||
|
||||
void party(cl_device_id device_id, cl_context context) {
|
||||
MultiCameraState cameras = {};
|
||||
VisionIpcServer vipc_server("camerad", device_id, context);
|
||||
|
||||
cameras_init(&vipc_server, &cameras, device_id, context);
|
||||
cameras_open(&cameras);
|
||||
|
||||
vipc_server.start_listener();
|
||||
|
||||
cameras_run(&cameras);
|
||||
}
|
||||
|
||||
#ifdef QCOM
|
||||
#include "CL/cl_ext_qcom.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (!Hardware::PC()) {
|
||||
int ret;
|
||||
@@ -52,18 +15,6 @@ int main(int argc, char *argv[]) {
|
||||
assert(ret == 0 || Params().getBool("IsOffroad")); // failure ok while offroad due to offlining cores
|
||||
}
|
||||
|
||||
cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT);
|
||||
|
||||
// TODO: do this for QCOM2 too
|
||||
#if defined(QCOM)
|
||||
const cl_context_properties props[] = {CL_CONTEXT_PRIORITY_HINT_QCOM, CL_PRIORITY_HINT_HIGH_QCOM, 0};
|
||||
cl_context context = CL_CHECK_ERR(clCreateContext(props, 1, &device_id, NULL, NULL, &err));
|
||||
#else
|
||||
cl_context context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err));
|
||||
#endif
|
||||
|
||||
party(device_id, context);
|
||||
|
||||
CL_CHECK(clReleaseContext(context));
|
||||
camerad_thread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#include "selfdrive/camerad/cameras/camera_common.h"
|
||||
|
||||
// needed by camera_common.cc
|
||||
ExitHandler do_exit;
|
||||
|
||||
void camera_autoexposure(CameraState *s, float grey_frac) {}
|
||||
void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) {}
|
||||
void cameras_open(MultiCameraState *s) {}
|
||||
void cameras_run(MultiCameraState *s) {}
|
||||
|
||||
int main() {
|
||||
// set up fake camerabuf
|
||||
|
||||
Reference in New Issue
Block a user