opencv: SimpleBlobDetector 使用

Mat image = GetDocument()->image; 
vector keyPoints; 
SimpleBlobDetector::Params params;


params.thresholdStep = 10;
params.minThreshold = 50;
params.maxThreshold = 220;
params.minRepeatability = 2;
params.minDistBetweenBlobs = 10;


params.filterByColor = true;
params.blobColor = 255;


params.filterByArea = true;
params.minArea = 25;
params.maxArea = 5000;


params.filterByCircularity = false;
params.minCircularity = 0.8f;
params.maxCircularity = std::numeric_limits::max();


params.filterByInertia = false;
//minInertiaRatio = 0.6;
params.minInertiaRatio = 0.1f;
params.maxInertiaRatio = std::numeric_limits::max();


params.filterByConvexity = true;
//minConvexity = 0.8;
params.minConvexity = 0.95f;
params.maxConvexity = std::numeric_limits::max();


double tt=getTickCount();


Ptr blobDetect=SimpleBlobDetector::create(params);
blobDetect->detect(image, keyPoints);


OutInfo("SimpleBlobDetector time",(getTickCount()-tt)*1000/getTickFrequency());


OutInfo("keypoints count",(long)keyPoints.size());  


drawKeypoints(image, keyPoints, image, Scalar(0,255,0));
namedWindow("blobs"); 

imshow("blobs", image); 


opencv: SimpleBlobDetector 使用_第1张图片

你可能感兴趣的:(opencv: SimpleBlobDetector 使用)