-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResultMonitor.cpp
44 lines (40 loc) · 957 Bytes
/
ResultMonitor.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
#include "ResultMonitor.h"
#include <opencv2/core/core_c.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
Mat ResultMonitor::Display(const Mat &frame, const IntRect &bbox)
{
RectVec r;
r.push_back(bbox);
return Display(frame, r);
}
Mat ResultMonitor::Display(const Mat &frame, const RectVec &rPool)
{
Mat result;
if (frame.type() == CV_8UC1)
{
cvtColor(frame, result, CV_GRAY2RGB);
}
else
{
frame.copyTo(result);
}
for (size_t i = 0; i < rPool.size(); ++i) {
if (i < Colors.size()) {
rectangle(result, rPool[i], Colors[i]);
}
else
{
rectangle(result, rPool[i], CV_RGB(0, 0, 0));
}
// color = CV_RGB(rand() % 256, rand() % 256, rand() % 256);
}
imshow(WindowName, result);
waitKey(1);
return result;
}
void ResultMonitor::rectangle(Mat& rMat, const IntRect& rRect, const Scalar& rColour) const
{
IntRect r(rRect);
cv::rectangle(rMat, Point(r.XMin(), r.YMin()), Point(r.XMax(), r.YMax()), rColour, thickness);
}