-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.cpp
72 lines (61 loc) · 1.27 KB
/
display.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "display.h"
Display::Display(QObject *parent) :
QThread(parent)
{
camera = 0;
stop = true;
}
void Display::setRun()
{
if (!isRunning()) {
if (isStopped()){ //isStopped return stop var value
stop = false;
}
start(LowPriority);
qDebug() << "Camera thread started";
}
}
void Display::run()
{
capture.open(camera); //open a camera
if( capture.isOpened() )
{
while(!stop)
{
capture >> frame;
cvtColor(frame, RGBframe, CV_BGR2RGB);
emit sendFrame(RGBframe); //emit frame for tracking
}
capture.release(); //shut down the camera
}
}
void Display::convertShow(cv::Mat RGBtemp)
{
image = QImage((const unsigned char*)(RGBtemp.data),
RGBtemp.cols,RGBtemp.rows,QImage::Format_RGB888);
emit showFrame(image); //signal to show processed image
}
bool Display::isStopped()
{
return this->stop;
}
void Display::setStop()
{
stop = true;
}
void Display::setCamera(int cam) //not tested
{
stop = true;
while (isRunning())
{
}
if (isStopped()){ //isStopped return stop var value
stop = false;
camera = cam;
}
start(LowPriority);
}
Display::~Display()
{
stop = true;
}