I want to detect blobs using opencv SimpleBlobDetector, in that class
cv::Ptr<cv::SimpleBlobDetector> detector = cv::SimpleBlobDetector::create(parameters);
detector->detect( inputImage, keypoints);
This works fine, until I want to introduce a mask so that the detector only looks for blobs within the mask.
detector->detect( inputImage, keypoints, zmat );
from the documentation, link, it says:
Mask specifying where to look for keypoints (optional). It must be a 8-bit integer matrix with non-zero values in the region of interest.
My understanding is that the detect algorithm will search only the non zero elements, in the mask matrix. So, I created a mask and populated this way::
cv::Mat zmat = cv::Mat::zeros(inputImage.size(), CV_8UC1);
cv::Scalar color(255,255,255);
cv::Rect rect(x,y,w,h);
cv::rectangle(zmat, rect, color, CV_FILLED);
However, it seems that the mask is not doing anything and the detect algorithm is detecting everything. I am using OpenCV 3.2. Thanks.
Aucun commentaire:
Enregistrer un commentaire