You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.9 KiB
C++
73 lines
1.9 KiB
C++
#ifndef _DEBUGTHREAD_H
|
|
#define _DEBUGTHREAD_H
|
|
#include <QThread>
|
|
#include <QDebug>
|
|
#include <QDateTime>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <opencv2/imgproc/types_c.h>
|
|
#include "SyncQueue.h"
|
|
#include "basecamera.h"
|
|
#include "common.h"
|
|
extern SyncQueue<cv::Mat> *g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列
|
|
|
|
extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度
|
|
extern bool isNeddRotate[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<cv::Mat> *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 (isNeddRotate[local_camera_number]) {
|
|
if(rotationAngle[local_camera_number] != (cv::ROTATE_90_COUNTERCLOCKWISE + 1))
|
|
{
|
|
cv::rotate(image, image, rotationAngle[local_camera_number]);
|
|
}
|
|
}
|
|
emit notify(local_camera_number,0,image);
|
|
}
|
|
}
|
|
}
|
|
public:
|
|
int local_camera_number;
|
|
int local_classid;
|
|
bool b_quit;
|
|
SyncQueue<cv::Mat> *p_debug_queue;
|
|
|
|
};
|
|
#endif //end of _DEBUGTHREAD_H
|