#ifndef _DEBUGTHREAD_H #define _DEBUGTHREAD_H #include #include #include #include #include #include "SyncQueue.h" #include "basecamera.h" #include "common.h" #include "balluffcamera.h" #include "hikcamera.h" extern SyncQueue* g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列 extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度 extern bool isNeedRotate[NumberOfSupportedCameras]; class DebugThread : public QThread { Q_OBJECT signals: void notify(int Num, int Cnt, cv::Mat); public: DebugThread(QObject* parent = 0) : QThread(parent) { } ~DebugThread() { stop(); p_debug_queue->put(cv::Mat()); quit(); wait(); } void init(SyncQueue* ptr, int Num) { local_camera_number = Num; b_quit = false; p_debug_queue = ptr; } void start_work() { start(HighestPriority); } void stop() { b_quit = true; } protected: void run() { while (!b_quit) { cv::Mat image; p_debug_queue->take(image); if (image.data) { //cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像 // 解决进入调试模式海康彩色相机变色,关闭色彩调整巴鲁夫相机变黑的问题 if (image.channels() == 1) { cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像 } if (isNeedRotate[local_camera_number]) { if (rotationAngle[local_camera_number] != (cv::ROTATE_90_COUNTERCLOCKWISE + 1)) { cv::rotate(image, image, rotationAngle[local_camera_number]); } } //sleep(100); emit notify(local_camera_number, 0, image); } #ifdef DRAW_RECT std::lock_guard locker2(g_display_label_conf[local_camera_number].lock); local_DisplayLabelConf.leftButtonDownFlag = g_display_label_conf[local_camera_number].leftButtonDownFlag; local_DisplayLabelConf.Flag[0] = g_display_label_conf[local_camera_number].Flag[0]; local_DisplayLabelConf.Flag[1] = g_display_label_conf[local_camera_number].Flag[1]; local_DisplayLabelConf.originalPoint = g_display_label_conf[local_camera_number].originalPoint; local_DisplayLabelConf.processPoint = g_display_label_conf[local_camera_number].processPoint; local_DisplayLabelConf.RectVet[0] = g_display_label_conf[local_camera_number].RectVet[0]; local_DisplayLabelConf.RectVet[1] = g_display_label_conf[local_camera_number].RectVet[1]; DrawSelectRects(image, local_DisplayLabelConf, 0); #endif } } public: int local_camera_number; int local_classid; bool b_quit; SyncQueue* p_debug_queue; DisplayLabelConf local_DisplayLabelConf; }; #endif //end of _DEBUGTHREAD_H