opencv画出轮廓外接矩形

     Mat cannyImage;
/// Detect edges using canny
Canny(src, cannyImage, , , );
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
/// Find contours
findContours(cannyImage, contours, hierarchy, CV_RETR_EXTERNAL /* CV_RETR_EXTERNAL CV_RETR_LIST CV_RETR_CCOMP RETR_TREE CV_RETR_FLOODFILL*/, CHAIN_APPROX_SIMPLE, Point(, )); /// Approximate contours to polygons + get bounding rects and circles
vector<vector<Point> > contours_poly(contours.size());
vector<Rect> boundRect(contours.size()); for (size_t i = ; i < contours.size(); i++)
{
approxPolyDP(Mat(contours[i]), contours_poly[i], , true);
boundRect[i] = boundingRect(Mat(contours_poly[i]));
}
上一篇:[FJOI2017]矩阵填数——容斥


下一篇:memcpy in place 数组内拷贝