Hi there, I've got a function which takes two Mat as parameters, const imgIn and ImgOut. ImgIn is a thresholded binary (either 0xffffffff or 0xff000000) image with two with blobs in them (I threshold two neon green balls that I use as markers). I want to use SimpleBlobDetector as demonstrated there : https://www.learnopencv.com/blob-detection-using-opencv-python-c/ . The img_with_keypoints being my imgOut so I can display in other part of my program. No matter what I tried so far, I keep running into an unhandled exception at function call myDetector->detect(imgIn, keypoints) even if both parameters seems valid when debugging. The imgIn comes from my webcam and start as a QImage (AARRGGBB). I successfully translate it in Mat and use it in cv::erode function... Does anyone have any clue on what could cause that?
Here is my code, which is mainly copied from the tutorial.
// Setup SimpleBlobDetector parameters.
SimpleBlobDetector::Params params;
params.filterByArea = true;
params.minArea = 100;
params.maxArea = 1000;
params.filterByColor = true;
params.blobColor = 255;
#if CV_MAJOR_VERSION < 3 // If you are using OpenCV 2
// Set up detector with params
SimpleBlobDetector detector(params);
// You can use the detector this way
// detector.detect( im, keypoints);
#else
// Set up detector with params
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
// SimpleBlobDetector::create creates a smart pointer.
// So you need to use arrow ( ->) instead of dot ( . )
// detector->detect( im, keypoints);
#endif
std::vector<cv::KeyPoint> keypoints;
detector->detect(imgIn, 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(imgIn, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imgOut = im_with_keypoints;
thank you for your time.