1、cvPolyLine 绘制简单或多样的多边形。
void cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int contours, int is_closed,
CvScalar color, int thickness=1, int line_type=8, int shift=0 );
img
图像。
pts
折线的顶点指针数组。
npts
折线的定点个数数组。也可以认为是pts指针数组的大小
contours
折线的线段数量。
is_closed 指出多边形是否封闭。如果封闭,函数将起始点和结束点连线。
color
折线的颜色。
thickness 线条的粗细程度。
line_type 线段的类型。参见cvLine。
shift
顶点的小数点位数。
void cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int contours, int is_closed,
img
pts
npts
contours
is_closed
color
thickness
line_type
shift
2、cvFillPoly用于一个单独被多边形轮廓所限定的区域内进行填充。函数可以填充复杂的区域,例如,有漏洞的区域和有交叉点的区域等等。
void cvFillPoly( CvArr* img, CvPoint** pts, int* npts, int contours,CvScalar color, int line_type=8, int shift=0 );
img
图像。
pts
指向多边形的数组指针。
npts
多边形的顶点个数的数组。
contours
组成填充区域的线段的数量。
color
多边形的颜色。
line_type 组成多边形的线条的类型。
shift
顶点坐标的小数点位数。
img
pts
npts
contours
color
line_type
shift
#include
"stdafx.h"
- #include
"cv.h" - #include
"highgui.h" - int
main(int argc, char* argv[]) - {
- char
wndname[] = "Drawing Demo"; - cvNamedWindow(wndname);
- int
arr[1]; - arr[0]
= 4; - CvPoint
** pt = new CvPoint*[1]; - pt[0]
= new CvPoint[4]; - pt[0][0]
= cvPoint(0,0); - pt[0][1]
= cvPoint(100,10); - pt[0][2]
= cvPoint(30,60); - pt[0][3]
= cvPoint(10,100); - IplImage*
image = cvCreateImage( cvSize(200,200), 8, 3 ); - cvPolyLine(
image, pt, arr, 1, 1, CV_RGB(250,0,0)); - cvFillPoly(image,pt,arr,1,CV_RGB(250,0,0));
- cvShowImage(wndname,image);
- cvWaitKey(1000000);
- return
0; - }