• opencv画出轮廓外接矩形


     1     Mat cannyImage;
     2     /// Detect edges using canny
     3     Canny(src, cannyImage, 125, 250, 3);
     4     vector<vector<Point> > contours;
     5     vector<Vec4i> hierarchy;
     6     /// Find contours
     7     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(0, 0));
     8 
     9     /// Approximate contours to polygons + get bounding rects and circles
    10     vector<vector<Point> > contours_poly(contours.size());
    11     vector<Rect> boundRect(contours.size());
    12 
    13     for (size_t i = 0; i < contours.size(); i++)
    14     {
    15         approxPolyDP(Mat(contours[i]), contours_poly[i], 3, true);
    16         boundRect[i] = boundingRect(Mat(contours_poly[i]));
    17     }
  • 相关阅读:
    Servlet
    反射
    Python之装饰器
    app——升级测试点
    Python之基本运算符
    HTTP常见的几种认证机制
    Shell文件包含
    Shell输入/输出重定向
    Shell函数
    Shell循环语句
  • 原文地址:https://www.cnblogs.com/supercxm/p/8458980.html
Copyright © 2020-2023  润新知