-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.cpp
More file actions
executable file
·49 lines (44 loc) · 1.04 KB
/
camera.cpp
File metadata and controls
executable file
·49 lines (44 loc) · 1.04 KB
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
#include "camera.h"
Camera::Camera(int index, QObject *parent):
QThread(parent)
{
cap = VideoCapture(index);
cap.set(CAP_PROP_FRAME_HEIGHT, 240);
cap.set(CAP_PROP_FRAME_WIDTH, 320);
}
void Camera::run()
{
while(true)
{
if(!camera_enable)
{
qDebug() << "camera thread end";
// camera_stop();
QThread::msleep(100);
// exec();
break;
}
mutex.lock();
cap >> image;
cvtColor(image, image_show, COLOR_BGR2RGB);
qimg = QImage(image_show.data, image_show.cols, image_show.rows, static_cast<int>(image_show.step), QImage::Format_RGB888);
emit q_captured(qimg);
emit img_captured(image);
image = Mat::zeros(image.rows, image.cols, CV_8UC3);
mutex.unlock();
}
}
Camera::~Camera()
{
cap.release();
qDebug() << "camera thread stop";
if(mutex.tryLock(200))
{
mutex.unlock();
}
}
//void Camera::camera_stop()
//{
// cap.release();
// qDebug() <<"camera stop";
//}