Problem implementing blob detector

asked 2018-04-28 09:30:32 -0500

Colin Peeris gravatar image

I'm tyring to implement a blob detector.... However, I keep getting this error

"OpenCV Error: The function/feature is not implemented () in cv::Feature2D::detectAndCompute, file C:\build\master_winpack-build-win64-vc14\opencv\modules\features2d\src\feature2d.cpp, line 154"

// Read image
Mat im = imread("blob.jpg", IMREAD_GRAYSCALE);

// Set up the detector with default parameters.
SimpleBlobDetector detector;

// Detect blobs.
std::vector<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
Mat im_with_keypoints;
drawKeypoints(im, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

// Show blobs
imshow("keypoints", im_with_keypoints);
waitKey(0);
edit retag flag offensive close merge delete

Comments

you must use :

Ptr<SimpleBlobDetector> detector= SimpleBlobDetector::create();

and

detector->detect(im, keypoints);
LBerger gravatar imageLBerger ( 2018-04-28 10:53:02 -0500 )edit

Thanks for the response. Somehow, it isn't working. I tried this....

// Read image

Mat im = imread("blob.jpg", IMREAD_GRAYSCALE);

// Set up the detector with default parameters.

Ptr<simpleblobdetector> detector = SimpleBlobDetector::create();

// Detect blobs.

std::vector<keypoint> keypoints; //detector.detect(im, 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

Mat im_with_keypoints;
drawKeypoints(im, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

// Show blobs
imshow("keypoints", im_with_keypoints); waitKey(0);

Colin Peeris gravatar imageColin Peeris ( 2018-04-28 11:41:20 -0500 )edit

There is an example in opencv detect_blob.cpp : you need to set param before detect

LBerger gravatar imageLBerger ( 2018-04-28 12:31:13 -0500 )edit