Add mask support to SimpleBlobDetector

pull/10902/head
mworchel 7 years ago committed by Alexander Alekhin
parent 88b689bcf1
commit aab390c51d
  1. 8
      modules/features2d/src/blobdetector.cpp

@ -304,11 +304,10 @@ void SimpleBlobDetectorImpl::findBlobs(InputArray _image, InputArray _binaryImag
#endif
}
void SimpleBlobDetectorImpl::detect(InputArray image, std::vector<cv::KeyPoint>& keypoints, InputArray)
void SimpleBlobDetectorImpl::detect(InputArray image, std::vector<cv::KeyPoint>& keypoints, InputArray mask)
{
CV_INSTRUMENT_REGION()
//TODO: support mask
keypoints.clear();
Mat grayscaleImage;
if (image.channels() == 3 || image.channels() == 4)
@ -372,6 +371,11 @@ void SimpleBlobDetectorImpl::detect(InputArray image, std::vector<cv::KeyPoint>&
KeyPoint kpt(sumPoint, (float)(centers[i][centers[i].size() / 2].radius) * 2.0f);
keypoints.push_back(kpt);
}
if (!mask.empty())
{
KeyPointsFilter::runByPixelsMask(keypoints, mask.getMat());
}
}
Ptr<SimpleBlobDetector> SimpleBlobDetector::create(const SimpleBlobDetector::Params& params)

Loading…
Cancel
Save