31 std::vector<std::vector<cv::Point> > retcontours;
35 cv::inRange(imghsv, cv::Scalar(hrange::get().min(), srange::get().min(), vrange::get().min()),
36 cv::Scalar(hrange::get().max(), srange::get().max(), vrange::get().max()), imgth);
39 cv::Mat erodeElement = getStructuringElement(cv::MORPH_RECT, cv::Size(erodesize::get(), erodesize::get()));
40 cv::erode(imgth, imgth, erodeElement);
42 cv::Mat dilateElement = getStructuringElement(cv::MORPH_RECT, cv::Size(dilatesize::get(), dilatesize::get()));
43 cv::dilate(imgth, imgth, dilateElement);
46 std::vector<std::vector<cv::Point> > contours; std::vector<cv::Vec4i> hierarchy;
47 cv::findContours(imgth, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_SIMPLE);
50 if (hierarchy.size() > 0 && hierarchy.size() <= maxnumobj::get())
51 for (
int index = 0; index >= 0; index = hierarchy[index][0])
54 std::vector<cv::Point>
const & c = contours[index];
56 cv::Moments moment = cv::moments(c);
57 double const area = moment.m00;
60 if (objectarea::get().contains(
int(
area + 0.4999))) retcontours.push_back(c);
std::vector< std::vector< cv::Point > > detect(cv::Mat const &imghsv)
Detect blobs, each is represented as a contour (vector of (x,y) coordinates)