Ask Your Question
0

Blob detector issue

asked 2015-03-06 12:51:22 -0600

Hello, I am trying to use SimpleBlobDetector with only one of its params; filterByCircularity. But it alone doesn't seems to detect even a perfect circle. I have tried it with the min and maximum range but that also does not helps. If I use filter by area in combination with it, it seems to work; because of the area filters i think.

Can you plz tell me the default values of min and maximum circularity?

Also has anyone tried using filterByCircularity alone? I was having a similar problem when using filterByColor as well.

params.filterByCircularity = true; params.minCircularity = 0.0; params.maxCircularity = 1;

Regards Saher Maqsood

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-03-07 20:32:19 -0600

theodore gravatar image

try something like that:

    Mat image = imread("circles.bmp"); // or whatever image you have with circles
    Ptr<FeatureDetector> blobsDetector = SimpleBlobDetector::create();
    vector<KeyPoint> keypoints;
    GaussianBlur( image, image, cv::Size(9, 9), 3, 3 );

    // Change parameters
    SimpleBlobDetector::Params params;
    params.filterByCircularity = true;
    blobsDetector->detect(image, keypoints);

    Mat drawImage = image.clone();
    for (size_t i = 0; i < keypoints.size(); ++i)
        circle(drawImage, keypoints[i].pt, 4, Scalar(255, 0, 255), -1);

    imshow("result", drawImage);

    waitKey(0);
    return 0;

this should work without a problem.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-06 12:51:22 -0600

Seen: 937 times

Last updated: Mar 07 '15