-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblob.cpp
More file actions
76 lines (47 loc) · 1.57 KB
/
blob.cpp
File metadata and controls
76 lines (47 loc) · 1.57 KB
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
#include "blob.hpp"
// blob::blob(){
// }
void blob::test_blob(cv::Mat frame)
{
cv::Mat im;
// Setup SimpleBlobDetector parameters.
cv::SimpleBlobDetector::Params params;
// Change thresholds
params.minThreshold = 150;
params.maxThreshold = 250;
// Filter by Area.
params.filterByArea = true;
params.minArea = 500;
// Filter by Circularity
params.filterByCircularity = true;
params.minCircularity = 0.2;
// Filter by Convexity
params.filterByConvexity = true;
params.minConvexity = 0.001;
// Filter by Inertia
params.filterByInertia = true;
params.minInertiaRatio = 0.01;
cv::SimpleBlobDetector detector(params);
// while(1)
// {
// mask.generateMask(frame);
// dilate(mask.blackMask, mask.blackMask, MORPH_ELLIPSE);
// bitwise_and(mask.blackMask, mask.whiteMask, frame);
im = frame;
cv::imshow("im", im );
// Mat im_erode;
// erode( im, im_erode, MORPH_ELLIPSE );
// imshow("im_erode", im_erode );
// // Set up the detector with default parameters.
//cv::SimpleBlobDetector detector;
// Detect blobs.
std::vector<cv::KeyPoint> keypoints;
detector.detect( im, keypoints);
// Draw detected blobs as red circles.
// DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
cv::Mat im_with_keypoints;
cv::drawKeypoints( im, keypoints, im_with_keypoints, cv::Scalar(0,0,255), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
// Show blobs
cv::imshow("keypoints.", im_with_keypoints );
//}
}