-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCvShapes.cpp
81 lines (65 loc) · 1.8 KB
/
CvShapes.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
73
74
75
76
77
78
79
80
#include "CvShapes.h"
#include <iostream>
void cvCross(CvArr* img, CvPoint pt, int size, CvScalar color, int thickness)
{
CvPoint left = pt + cv::Point(-size, 0);
CvPoint right = pt + cv::Point(size, 0);
CvPoint up = pt + cv::Point(0, -size);
CvPoint down = pt + cv::Point(0, size);
cvLine(img, left, right, color, thickness);
cvLine(img, up, down, color, thickness);
}
CvPoint operator+(CvPoint a, CvPoint b)
{
CvPoint ret = cv::Point(a.x + b.x, a.y + b.y);
return ret;
}
CvPoint operator-(CvPoint a, CvPoint b)
{
CvPoint ret = cv::Point(a.x - b.x, a.y - b.y);
return ret;
}
CvPoint operator*(CvPoint a, double scalar)
{
CvPoint ret = cv::Point(a.x * scalar, a.y *scalar);
return ret;
}
CvPoint operator*(CvPoint a, CvPoint b)
{
CvPoint ret = cv::Point(a.x * b.x, a.y * b.y);
return ret;
}
CvPoint operator/(CvPoint a, CvPoint b)
{
return cv::Point(a.x / b.x, a.y / b.y);
}
CvPoint operator/(CvPoint a, double scalar)
{
return cv::Point(a.x / scalar, a.y / scalar);
}
CvPoint FlipHorizontal(CvPoint a, int ImageHeight)
{
double center_line = ImageHeight / 2.0;
return cv::Point(a.x, -(center_line - a.y));
}
CvPoint operator+=(CvPoint a, CvPoint b)
{
return cv::Point(a.x + b.x, a.y + b.y);
}
std::ostream& operator<<(std::ostream& s, const cv::Mat& mat)
{
s << "[Channels: " << mat.channels() << "][Size: W:" << mat.size().width << ";H: " << mat.size().height << "][Rows: " << mat.rows << "][Cols: " << mat.cols << "]";
return s;
}
std::ostream& operator<<(std::ostream& s, const CvPoint& point)
{
s << "[" << point.x << ":" << point.y << "]";
return s;
}
bool EllipseOK(CvBox2D box)
{
bool bRet = false;
double aspect = box.size.width / box.size.height;
bRet = (0.1 < aspect & aspect < 0.8 );
return bRet;
}