1 | initial version |
The task is solved using convexHull() function.
vector<vector<Point> > contours_poly(contours.size());
vector<Point> contours_dots;
vector<Point> conv_hull;
Point dot;
for (size_t i = 0; i < contours.size(); i++)
{
approxPolyDP(Mat(contours[i]), contours_poly[i], 3, true);
}
for (size_t i = 0; i < contours.size(); i++)
{
for (size_t j = 0; j < contours[i].size(); j++)
{
dot = contours[i][j];
contours_dots.push_back(dot);
}
}
convexHull(contours_dots, conv_hull);
contours_poly.push_back(conv_hull);