From eef068972bf46cb1f9c0feceb090cc894c48bf50 Mon Sep 17 00:00:00 2001 From: Flamingo Date: Tue, 9 Jul 2024 23:45:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9B=B8=E6=9C=BANG/OK?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=88=E5=B9=B6=E5=92=8C=E5=88=86=E5=BC=80?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=9A=84=E5=AE=8F=EF=BC=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cigarette/cigarette.cpp | 30 +++++++++++++++++------------- Cigarette/common.h | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index f7cd328..35143d6 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -2892,8 +2892,12 @@ void Cigarette::init_plc_value() void Cigarette::CreatWorkThread(int classid, int Num, Cigarette* classptr) { + int CamId = Num; #ifdef SYNC_CAMERA - sync_work_thread.init(g_image_sync_queue, g_result_queue[0]); +#ifdef IS_CAM_NG_OK_DATA_MERGED + CamId = 0; // 默认使用第一个相机的数据 +#endif + sync_work_thread.init(g_image_sync_queue, g_result_queue[CamId]); connect(&sync_work_thread, SIGNAL(notify(int, int, cv::Mat)), classptr, SLOT(OnNotifyHub(int, int, cv::Mat))); connect(&sync_work_thread, SIGNAL(display_timecost(int, int)), classptr, SLOT(OnDisplayTimeCostHub(int, int))); connect(&sync_work_thread, SIGNAL(display_check_total(int, long)), classptr, SLOT(OnDisplayCheckNumberHub(int, long))); @@ -2902,18 +2906,18 @@ void Cigarette::CreatWorkThread(int classid, int Num, Cigarette* classptr) connect(&sync_work_thread, SIGNAL(event_ng(int)), classptr, SLOT(OnNGHub(int))); sync_work_thread.start_work(); #else - work_thread[Num].init(g_image_queue[Num], g_result_queue[Num], classid, Num); - connect(&work_thread[Num], SIGNAL(notify(int, int, cv::Mat)), classptr, SLOT(OnNotifyHub(int, int, cv::Mat))); - connect(&work_thread[Num], SIGNAL(display_timecost(int, int)), classptr, SLOT(OnDisplayTimeCostHub(int, int))); - connect(&work_thread[Num], SIGNAL(display_check_total(int, long)), classptr, SLOT(OnDisplayCheckNumberHub(int, long))); - connect(&work_thread[Num], SIGNAL(display_jd_no(int, QString)), classptr, SLOT(OnDisplayJdNoHub(int, QString))); - connect(&work_thread[Num], SIGNAL(event_ok(int)), classptr, SLOT(OnOKHub(int))); - connect(&work_thread[Num], SIGNAL(event_ng(int)), classptr, SLOT(OnNGHub(int))); - work_thread[Num].start_work(); - - debug_thread[Num].init(g_debug_queue[Num], Num); - connect(&debug_thread[Num], SIGNAL(notify(int, int, cv::Mat)), classptr, SLOT(OnNotifyHub(int, int, cv::Mat))); - debug_thread[Num].start_work(); + work_thread[CamId].init(g_image_queue[CamId], g_result_queue[CamId], classid, CamId); + connect(&work_thread[CamId], SIGNAL(notify(int, int, cv::Mat)), classptr, SLOT(OnNotifyHub(int, int, cv::Mat))); + connect(&work_thread[CamId], SIGNAL(display_timecost(int, int)), classptr, SLOT(OnDisplayTimeCostHub(int, int))); + connect(&work_thread[CamId], SIGNAL(display_check_total(int, long)), classptr, SLOT(OnDisplayCheckNumberHub(int, long))); + connect(&work_thread[CamId], SIGNAL(display_jd_no(int, QString)), classptr, SLOT(OnDisplayJdNoHub(int, QString))); + connect(&work_thread[CamId], SIGNAL(event_ok(int)), classptr, SLOT(OnOKHub(int))); + connect(&work_thread[CamId], SIGNAL(event_ng(int)), classptr, SLOT(OnNGHub(int))); + work_thread[CamId].start_work(); + + debug_thread[CamId].init(g_debug_queue[CamId], CamId); + connect(&debug_thread[CamId], SIGNAL(notify(int, int, cv::Mat)), classptr, SLOT(OnNotifyHub(int, int, cv::Mat))); + debug_thread[CamId].start_work(); #endif } diff --git a/Cigarette/common.h b/Cigarette/common.h index e76a790..2c35598 100644 --- a/Cigarette/common.h +++ b/Cigarette/common.h @@ -33,6 +33,7 @@ //#define identify_Hik_YSXID//识别海康相机YSXID //#define DRAW_RECT // 鼠标画框功能 #define SYNC_CAMERA //相机同步处理图片 +#define IS_CAM_NG_OK_DATA_MERGED //合并相机NG/OK数据 #define Queue_Size 15 #define Unit_Queue_Size Queue_Size*3