cvPolyLine与cvFillPoly的用法

来源:互联网 发布:计算器在windows 编辑:程序博客网 时间:2024/06/05 06:26
http://blog.csdn.net/schoolers/article/details/4738430
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          顶点的小数点位数。

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          顶点坐标的小数点位数。

[cpp] view plaincopyprint?
  1. #include "stdafx.h" 
  2. #include "cv.h" 
  3. #include "highgui.h" 
  4. int main(int argc,char* argv[]) 
  5. char wndname[] = "Drawing Demo"
  6. cvNamedWindow(wndname); 
  7. int arr[1]; 
  8. arr[0] = 4; 
  9. CvPoint ** pt = new CvPoint*[1]; 
  10. pt[0] = new CvPoint[4]; 
  11. pt[0][0] = cvPoint(0,0); 
  12. pt[0][1] = cvPoint(100,10); 
  13. pt[0][2] = cvPoint(30,60); 
  14. pt[0][3] = cvPoint(10,100); 
  15. IplImage* image = cvCreateImage( cvSize(200,200), 8, 3 ); 
  16. cvPolyLine( image, pt, arr, 1, 1, CV_RGB(250,0,0)); 
  17. cvFillPoly(image,pt,arr,1,CV_RGB(250,0,0)); 
  18. cvShowImage(wndname,image); 
  19. cvWaitKey(1000000); 
  20. return 0; 
  21. }

0 0
原创粉丝点击