summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT/point_extractor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'FTNoIR_Tracker_PT/point_extractor.cpp')
-rw-r--r--FTNoIR_Tracker_PT/point_extractor.cpp80
1 files changed, 40 insertions, 40 deletions
diff --git a/FTNoIR_Tracker_PT/point_extractor.cpp b/FTNoIR_Tracker_PT/point_extractor.cpp
index a415f24e..b26f7068 100644
--- a/FTNoIR_Tracker_PT/point_extractor.cpp
+++ b/FTNoIR_Tracker_PT/point_extractor.cpp
@@ -66,44 +66,44 @@ const vector<Vec2f>& PointExtractor::extract_points(Mat frame, float dt, bool dr
}
//*/
- // Method 2: floodfill
- /*
- // extract blobs
- struct BlobInfo
- {
- BlobInfo() : m00(0), m10(0), m01(0) {}
- long m00;
- long m10;
- long m01;
- };
- vector<BlobInfo> blobs;
- int blob_count = 1;
-
- for (int y=0; y < frame_bw.rows; y++) {
- for (int x=0; x < frame_bw.cols; x++) {
- if (frame_bw.at<unsigned char>(y,x) != 255) continue;
- Rect rect;
- floodFill(frame_bw, Point(x,y), Scalar(blob_count), &rect, Scalar(0), Scalar(0), 4);
- BlobInfo blob;
- for (int i=rect.y; i < (rect.y+rect.height); i++) {
- for (int j=rect.x; j < (rect.x+rect.width); j++) {
- if (frame_bw.at<unsigned char>(i,j) != blob_count) continue;
- blob.m00++;
- blob.m01+=i;
- blob.m10+=j;
- }
- }
- blobs.push_back(blob);
- blob_count++;
- if (blob_count >= 255) break;
- }
- }
-
- // extract points
- Vec2f c;
- points.clear();
- float m00_min = 3.14*min_size*min_size;
- float m00_max = 3.14*max_size*max_size;
+ // Method 2: floodfill
+ /*
+ // extract blobs
+ struct BlobInfo
+ {
+ BlobInfo() : m00(0), m10(0), m01(0) {}
+ long m00;
+ long m10;
+ long m01;
+ };
+ vector<BlobInfo> blobs;
+ int blob_count = 1;
+
+ for (int y=0; y < frame_bw.rows; y++) {
+ for (int x=0; x < frame_bw.cols; x++) {
+ if (frame_bw.at<unsigned char>(y,x) != 255) continue;
+ Rect rect;
+ floodFill(frame_bw, Point(x,y), Scalar(blob_count), &rect, Scalar(0), Scalar(0), 4);
+ BlobInfo blob;
+ for (int i=rect.y; i < (rect.y+rect.height); i++) {
+ for (int j=rect.x; j < (rect.x+rect.width); j++) {
+ if (frame_bw.at<unsigned char>(i,j) != blob_count) continue;
+ blob.m00++;
+ blob.m01+=i;
+ blob.m10+=j;
+ }
+ }
+ blobs.push_back(blob);
+ blob_count++;
+ if (blob_count >= 255) break;
+ }
+ }
+
+ // extract points
+ Vec2f c;
+ points.clear();
+ float m00_min = 3.14*min_size*min_size;
+ float m00_max = 3.14*max_size*max_size;
for (vector<BlobInfo>::iterator iter = blobs.begin();
iter!= blobs.end();
++iter)
@@ -114,8 +114,8 @@ const vector<Vec2f>& PointExtractor::extract_points(Mat frame, float dt, bool dr
c[0] = (m.m10/float(m.m00) - frame.cols/2)/frame.cols;
c[1] = -(m.m01/float(m.m00) - frame.rows/2)/frame.cols;
points.push_back(c);
- }
- */
+ }
+ */
// draw output image
if (draw_output)