@@ -31,6 +31,8 @@ double calcCircularity(vector<Point> contour) {
31
31
32
32
/* Finds all the rectangles in a region */
33
33
vector<vector<Point> > findAllRectangles (Mat& mbgra) {
34
+ LOGI (" Finding rectangles..." );
35
+
34
36
int width = mbgra.size [1 ];
35
37
int height = mbgra.size [0 ];
36
38
@@ -55,19 +57,16 @@ vector<vector<Point> > findAllRectangles(Mat& mbgra) {
55
57
*/
56
58
vector<vector<Point> > contours;
57
59
findContours (thresh, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);// ###
58
- // LOGI("Contours: %d", contours.size());
60
+ LOGI (" Contours: %d" , contours.size ());
59
61
60
62
61
63
/*
62
64
For each contour, find out how rectangle it is (between .5 and 1 is a pretty good rectangle candidate)
63
65
*/
64
66
vector<vector<Point> > checkboxes;
65
- // checkboxes.push_back (contours[0]);
66
-
67
67
for (int i = 0 ; i < contours.size (); i++) {
68
68
Rect rect = boundingRect (contours[i]);
69
69
70
-
71
70
// Make contour convex QUESTION: why?
72
71
vector<Point> convex;
73
72
convexHull (contours[i], convex);
@@ -79,7 +78,7 @@ vector<vector<Point> > findAllRectangles(Mat& mbgra) {
79
78
continue ;
80
79
checkboxes.push_back (convex);
81
80
}
82
- // LOGI("Potential Checkboxes: %d", checkboxes.size());
81
+ LOGI (" Potential Checkboxes: %d" , checkboxes.size ());
83
82
84
83
85
84
checkboxes = filterSquareByArea (checkboxes);
@@ -137,6 +136,15 @@ vector<vector<Point> > getCropOfToDoLines(vector<vector<Point> > checkboxes, Mat
137
136
d), Scalar (200 , 200 , 0 , 255 ), 2 );
138
137
139
138
139
+ // Draw cross-hairs
140
+ int width = mbgra.size [0 ];
141
+ int height = mbgra.size [1 ];
142
+ line (mbgra, Point (width * 0.5 , height * 0.4 ),
143
+ Point (width * 0.5 , height * 0.6 ), Scalar (0 , 0 , 0 , 255 ), 2 );
144
+ line (mbgra, Point (width * 0.4 , height * 0.5 ),
145
+ Point (width * 0.6 , height * 0.5 ), Scalar (0 , 0 , 0 , 255 ), 2 );
146
+
147
+
140
148
// cvLine(mbgra, pt1, pt2, Scalar(0, 200,200, 255), 2)
141
149
Mat imgroi = mbgra (Rect (a, b, c, d));
142
150
0 commit comments