diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index 35143d6..bd900ad 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -2892,12 +2892,8 @@ void Cigarette::init_plc_value() void Cigarette::CreatWorkThread(int classid, int Num, Cigarette* classptr) { - int CamId = Num; #ifdef SYNC_CAMERA -#ifdef IS_CAM_NG_OK_DATA_MERGED - CamId = 0; // 默认使用第一个相机的数据 -#endif - sync_work_thread.init(g_image_sync_queue, g_result_queue[CamId]); + sync_work_thread.init(g_image_sync_queue, g_result_queue, 0); // 默认使用第一个相机的数据 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))); @@ -2906,18 +2902,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[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(); + 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(); #endif } diff --git a/Cigarette/syncworkthread.cpp b/Cigarette/syncworkthread.cpp index 1061851..402ec53 100644 --- a/Cigarette/syncworkthread.cpp +++ b/Cigarette/syncworkthread.cpp @@ -43,11 +43,12 @@ SyncWorkThread::~SyncWorkThread() wait(); } -void SyncWorkThread::init(SyncQueue>>* image_ptr, ASyncQueue* result_ptr) +void SyncWorkThread::init(SyncQueue>>* image_ptr, ASyncQueue* result_ptr[], int MergeToCamId) { local_g_image_sync_queue = image_ptr; local_g_result_queue = result_ptr; b_quit = false; + MergeToCamId = MergeToCamId; for (int i = 0; i < NumberOfSupportedCameras; i++) { frame_total[i] = 0; } @@ -70,7 +71,9 @@ void SyncWorkThread::run() QDateTime now_ts = QDateTime::currentDateTime(); std::vector> element_vec; local_g_image_sync_queue->take(element_vec); +#ifdef IS_CAM_NG_OK_DATA_MERGED bool IsNGForAll = false; +#endif int merge_index; cv::Mat merge_image = cv::Mat::zeros(image_h * g_sys_conf.shoot[0], image_w * work_camera_nums, CV_8UC3);//640*work_camera_nums cv::Rect roi; @@ -260,7 +263,9 @@ void SyncWorkThread::run() #ifdef SYNC_CAMERA emit event_ok(local_camera_number); #endif - // local_g_result_queue->put(true); +#ifndef IS_CAM_NG_OK_DATA_MERGED + local_g_result_queue[local_camera_number]->put(true); +#endif } } else @@ -271,8 +276,11 @@ void SyncWorkThread::run() #ifdef SYNC_CAMERA emit event_ng(local_camera_number); #endif - //local_g_result_queue->put(false); +#ifndef IS_CAM_NG_OK_DATA_MERGED + local_g_result_queue[local_camera_number]->put(false); +#else IsNGForAll = TRUE; +#endif } if ((local_SysConf.save == 2) || (local_SysConf.save == 1)) @@ -375,16 +383,18 @@ void SyncWorkThread::run() #endif j++; } +#ifdef IS_CAM_NG_OK_DATA_MERGED if (IsNGForAll) { - local_g_result_queue->put(false); + local_g_result_queue[MergeToCamId]->put(false); } else { - local_g_result_queue->put(true); + local_g_result_queue[MergeToCamId]->put(true); } +#endif // emit display_check_total(local_camera_number, ++(frame_total[local_camera_number])); } } diff --git a/Cigarette/syncworkthread.h b/Cigarette/syncworkthread.h index e2231ed..879c0ac 100644 --- a/Cigarette/syncworkthread.h +++ b/Cigarette/syncworkthread.h @@ -30,15 +30,16 @@ public: } ~SyncWorkThread(); - void init(SyncQueue>>* image_ptr, ASyncQueue* result_ptr); + void init(SyncQueue>>* image_ptr, ASyncQueue* result_ptr[], int MergeToCamId); void start_work(); void stop(); protected: void run(); + int MergeToCamId; public: int local_camera_number; SyncQueue>>* local_g_image_sync_queue; - ASyncQueue* local_g_result_queue; + ASyncQueue** local_g_result_queue; bool b_quit; long frame_total[NumberOfSupportedCameras]; SysConf local_SysConf;