Skip to content

Commit b70e5aa

Browse files
committed
drawing lines and debugging why the HTC desire finds no Contours, most likley due to not receiving an image
1 parent cd7ae02 commit b70e5aa

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

android/jni/imagefuncs.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ double calcCircularity(vector<Point> contour) {
3131

3232
/* Finds all the rectangles in a region */
3333
vector<vector<Point> > findAllRectangles(Mat& mbgra) {
34+
LOGI("Finding rectangles...");
35+
3436
int width = mbgra.size[1];
3537
int height = mbgra.size[0];
3638

@@ -55,19 +57,16 @@ vector<vector<Point> > findAllRectangles(Mat& mbgra) {
5557
*/
5658
vector<vector<Point> > contours;
5759
findContours(thresh, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);//###
58-
//LOGI("Contours: %d", contours.size());
60+
LOGI("Contours: %d", contours.size());
5961

6062

6163
/*
6264
For each contour, find out how rectangle it is (between .5 and 1 is a pretty good rectangle candidate)
6365
*/
6466
vector<vector<Point> > checkboxes;
65-
//checkboxes.push_back (contours[0]);
66-
6767
for (int i = 0; i < contours.size(); i++) {
6868
Rect rect = boundingRect(contours[i]);
6969

70-
7170
// Make contour convex QUESTION: why?
7271
vector<Point> convex;
7372
convexHull(contours[i], convex);
@@ -79,7 +78,7 @@ vector<vector<Point> > findAllRectangles(Mat& mbgra) {
7978
continue;
8079
checkboxes.push_back (convex);
8180
}
82-
//LOGI("Potential Checkboxes: %d", checkboxes.size());
81+
LOGI("Potential Checkboxes: %d", checkboxes.size());
8382

8483

8584
checkboxes = filterSquareByArea(checkboxes);
@@ -137,6 +136,15 @@ vector<vector<Point> > getCropOfToDoLines(vector<vector<Point> > checkboxes, Mat
137136
d), Scalar(200, 200, 0, 255), 2);
138137

139138

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+
140148
//cvLine(mbgra, pt1, pt2, Scalar(0, 200,200, 255), 2)
141149
Mat imgroi = mbgra(Rect(a, b, c, d));
142150

0 commit comments

Comments
 (0)