mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
camerad use std::thread (#19771)
old-commit-hash: 1b3c93813d37e09b0c695a9974cfc8789373352c
This commit is contained in:
@@ -1557,9 +1557,7 @@ static FrameMetadata get_frame_metadata(CameraState *s, uint32_t frame_id) {
|
||||
};
|
||||
}
|
||||
|
||||
static void* ops_thread(void* arg) {
|
||||
MultiCameraState *s = (MultiCameraState*)arg;
|
||||
|
||||
static void ops_thread(MultiCameraState *s) {
|
||||
int rear_op_id_last = 0;
|
||||
int front_op_id_last = 0;
|
||||
|
||||
@@ -1584,8 +1582,6 @@ static void* ops_thread(void* arg) {
|
||||
|
||||
util::sleep_for(50);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void update_lapmap(MultiCameraState *s, const CameraBuf *b, const int cnt) {
|
||||
@@ -1679,10 +1675,8 @@ void camera_process_frame(MultiCameraState *s, CameraState *c, int cnt) {
|
||||
}
|
||||
|
||||
void cameras_run(MultiCameraState *s) {
|
||||
pthread_t ops_thread_handle;
|
||||
int err = pthread_create(&ops_thread_handle, NULL, ops_thread, s);
|
||||
assert(err == 0);
|
||||
std::vector<std::thread> threads;
|
||||
threads.push_back(std::thread(ops_thread, s));
|
||||
threads.push_back(start_process_thread(s, "processing", &s->rear, camera_process_frame));
|
||||
threads.push_back(start_process_thread(s, "frontview", &s->front, camera_process_front));
|
||||
|
||||
@@ -1778,9 +1772,6 @@ void cameras_run(MultiCameraState *s) {
|
||||
|
||||
LOG(" ************** STOPPING **************");
|
||||
|
||||
err = pthread_join(ops_thread_handle, NULL);
|
||||
assert(err == 0);
|
||||
|
||||
for (auto &t : threads) t.join();
|
||||
|
||||
cameras_close(s);
|
||||
|
||||
@@ -1070,8 +1070,7 @@ void camera_autoexposure(CameraState *s, float grey_frac) {
|
||||
cam_exp[s->camera_num].store(tmp);
|
||||
}
|
||||
|
||||
static void* ae_thread(void* arg) {
|
||||
MultiCameraState *s = (MultiCameraState*)arg;
|
||||
static void ae_thread(MultiCameraState *s) {
|
||||
CameraState *c_handles[3] = {&s->wide, &s->rear, &s->front};
|
||||
|
||||
int op_id_last[3] = {0};
|
||||
@@ -1090,8 +1089,6 @@ static void* ae_thread(void* arg) {
|
||||
|
||||
util::sleep_for(50);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void camera_process_front(MultiCameraState *s, CameraState *c, int cnt) {
|
||||
@@ -1135,14 +1132,9 @@ void camera_process_frame(MultiCameraState *s, CameraState *c, int cnt) {
|
||||
}
|
||||
|
||||
void cameras_run(MultiCameraState *s) {
|
||||
int err;
|
||||
// start threads
|
||||
LOG("-- Starting threads");
|
||||
pthread_t ae_thread_handle;
|
||||
err = pthread_create(&ae_thread_handle, NULL,
|
||||
ae_thread, s);
|
||||
assert(err == 0);
|
||||
std::vector<std::thread> threads;
|
||||
threads.push_back(std::thread(ae_thread, s));
|
||||
threads.push_back(start_process_thread(s, "processing", &s->rear, camera_process_frame));
|
||||
threads.push_back(start_process_thread(s, "frontview", &s->front, camera_process_front));
|
||||
threads.push_back(start_process_thread(s, "wideview", &s->wide, camera_process_frame));
|
||||
@@ -1193,9 +1185,6 @@ void cameras_run(MultiCameraState *s) {
|
||||
|
||||
LOG(" ************** STOPPING **************");
|
||||
|
||||
err = pthread_join(ae_thread_handle, NULL);
|
||||
assert(err == 0);
|
||||
|
||||
for (auto &t : threads) t.join();
|
||||
|
||||
cameras_close(s);
|
||||
|
||||
Reference in New Issue
Block a user