-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
49 lines (38 loc) · 1.13 KB
/
main.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
#include "PJCalibDetector.h"
#include <ctime>
int main()
{
/* Get the image */
Mat *image = new Mat;
*image = imread("TestImage5.png", 1);
if(!image->data)
//throw exception("Unable to open image.");
return 0;
PJCalibDetector calibDetector(image);
try
{
vector<Point> blueRectangle;
clock_t start = clock();
calibDetector.FindBlueRectangle(blueRectangle);
clock_t ends = clock();
cout << "Detection Time: " << (double) (ends - start) / CLOCKS_PER_SEC << endl;
/* Display the lines */
line(*image, blueRectangle[0], blueRectangle[1], CV_RGB(255, 0, 0), 2, 8);
line(*image, blueRectangle[1], blueRectangle[2], CV_RGB(255, 0, 0), 2, 8);
line(*image, blueRectangle[2], blueRectangle[3], CV_RGB(255, 0, 0), 2, 8);
line(*image, blueRectangle[3], blueRectangle[0], CV_RGB(255, 0, 0), 2, 8);
/* Display the corners */
for(int i=0; i<blueRectangle.size(); i++)
{
circle(*image, blueRectangle[i], 1, CV_RGB(255, 255, 0), 2, 8);
}
//calibDetector.OrderCorners(image, blueRectangle);
imshow("Test4", *image);
waitKey(0);
}
catch(exception& ex)
{
cout << ex.what() << endl;
}
waitKey(0);
}