polylines()//只能绘制多边形,不能填充
void cv::polylines(
InputOutputArray img,
InputArrayOfArrays pts,
bool isClosed,
const Scalar & color,
int thickness = 1,
int lineType = LINE_8,
int shift = 0
)
img表示绘制画布,图像
pts表示多边形的点
isClosed表示是否闭合,默认闭合
color表示颜色
thickness表示线宽,必须是正数
lineType表示线渲染类型
shift表示相对位移
fillPoly() //填充多边形
drawContours() //可同时绘制填充多个多边形
需要提前构造多个点集的多边形
void drawContours(
InputOutputArray image,
InputArrayOfArrays contours,
int contourIdx,
const Scalar& color,
int thickness=1,
int lineType=8,
InputArray hierarchy=noArray(),
int maxLevel=INT_MAX, Point offset=Point() )
参数image 表示 目标图像,
参数contours 表示输入的轮廓组,每一组轮廓由点vector构成,
参数contourIdx 为画第几个轮廓,如果该参数为负值,则画全部轮廓,
参数color为轮廓的颜色,
参数thickness为轮廓的线宽,如果为负值或CV_FILLED表示填充轮廓内部,
参数 lineType 为 线型,
参数为 轮廓结构 信息,
参数为 maxLevel
如:std::vector<std::vector > contours;
contours.push_back(pts);
//drawContours(canvas, contours,-1, Scalar(255,0, 0),0); //一次性绘制多个
drawContours(canvas, contours, -1, Scalar(255, 0, 0),-1); //一次性填充绘制函数
void QuickDemo::polygon_drawing_demo(Mat