-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathThreads.cpp
More file actions
60 lines (56 loc) · 1.17 KB
/
Copy pathThreads.cpp
File metadata and controls
60 lines (56 loc) · 1.17 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
50
51
52
53
54
55
56
57
58
59
60
#include "Threads.h"
CameraDisplay::~CameraDisplay()
{
videocapture->release();
delete videocapture;
}
cv::Mat CameraDisplay::GetFrame()
{
mutex.lock();
res = matFrame.clone();
mutex.unlock();
return this->res;
}
/// <summary>
/// 得到瞬时帧率,不代表实际帧率
/// </summary>
/// <returns></returns>
double CameraDisplay::GetFPS()
{
double fps = 0;
if (videocapture->isOpened())
fps = 1000 / fpsInv;
return fps;
}
void CameraDisplay::run()
{
isStart = true;
clock_t start, end;
while (isStart)
{
start = clock();
cv::Mat graymat;
std::vector<cv::Point2f> corner;
mutex.lock();
videocapture->read(matFrame);
cv::cvtColor(matFrame, graymat, CV_BGR2GRAY);
bool isFind;
//对称圆形矩阵标定板
isFind = findCirclesGrid(graymat, cv::Size(7, 7), corner, cv::CALIB_CB_SYMMETRIC_GRID);
if (isFind)
drawChessboardCorners(matFrame, cv::Size(7, 7), corner, isFind);
imshow(winName, matFrame);
mutex.unlock();
end = clock();
fpsInv = end - start;
}
}
void CameraDisplay::StopThread()
{
isStart = false;
}
CameraDisplay::CameraDisplay(int CameraID,std::string winName, QObject* parent)
{
this->winName = winName;
videocapture = new cv::VideoCapture(CameraID);
}