vector<vector<Point>> contours;
findContours(pin_mask, contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
vector<vector<Point>>filterContours;
double minArea = 1000;
double maxArea = 100000;
vector<RotatedRect> boxes;
vector<Point2f> centers;
for (auto &contour : contours) {
double area = contourArea(contour);
if (area > minArea) {
RotatedRect box = minAreaRect(Mat(contour));
Point2f rect[4];
box.points(rect);
Point2f center = box.center;
centers.push_back(center);
boxes.push_back(box);
for (int j = 0; j < 4; j++) {
line(pin_mask, rect[j], rect[(j + 1) % 4], 130, 2, LINE_AA);
}
circle(pin_mask, center, 2, 100, -1);
filterContours.push_back(contour);
}
}
07-07
1125