当前位置:   article > 正文

Opencv_14_多边形填充与绘制

Opencv_14_多边形填充与绘制

绘制多边形:   

1)coInvert.polyline_drawing(src);

2)void ColorInvert::polyline_drawing(Mat& image)
{
    Mat canvas = Mat::zeros(Size(512, 512), CV_8UC3);
    Point p1(100, 100);
    Point p2(150, 100);
    Point p3(200, 150);
    Point p4(220, 200);
    Point p5(80, 230);
    std::vector<Point>pts;
    pts.push_back(p1);
    pts.push_back(p2);
    pts.push_back(p3);
    pts.push_back(p4);
    pts.push_back(p5);
   
    //fillPoly(canvas, pts,Scalar(255, 255, 255),6,0);
    //polylines(canvas, pts, true, Scalar(0, 0, 255), 1, 8); //该函数不能进行填充
    std::vector<std::vector<Point>>contours;
    contours.push_back(pts);
    //drawContours(canvas, contours, -1, Scalar(255, 0, 0), 2);

    drawContours(canvas, contours, -1, Scalar(255, 0, 0), -1); //最后一个参数小于0 进行填充


 
    imshow("多边形绘制", canvas);
}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/484787
推荐阅读
相关标签
  

闽ICP备14008679号