I'm trying to write a code for Blob detection and I'm following the tutorial here https://www.learnopencv.com/blob-detection-using-opencv-python-c/ I've just copied and pasted the code
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);
when I run it I get an error at
drawKeypoints(im, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
saying "unhandled exception", : Microsoft C++: cv::Exception
How can I solve this?
Ok after going through the tutorial without coding, I've realized that the code that is posted at the beginning of the article does not specifiy the parameters for the detector. After specifying them the program now works fine. Here's the full code: