Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cv::findContours(thresh, cnts, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
- current_result = img->clone();
- for (int i = 0; i < cnts.size(); i++) {
- std::pair<int, int> x = { img->size().width, 0 }, y = { img->size().height, 0 };
- for (int z = 0; z < cnts[i].size(); ++z) {
- x.first = std::min(cnts[i][z].x, x.first);
- x.second = std::max(cnts[i][z].x, x.second);
- y.first = std::min(cnts[i][z].y, y.first);
- y.second = std::max(cnts[i][z].y, y.second);
- }
- cv::Rect bb(x.first, y.first, x.second - x.first, y.second - y.first);
- if (bb.area() < settings_.lower_area) continue;
- if (bb.area() > settings_.upper_area) continue;
- detection_result = true;
- cv::rectangle(current_result, bb, cv::Scalar(0, 0, 255));
- }
- return detection_result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement