Opencv学习之fillPoly函数:绘制多边形并对其填充

fillPoly(img,ppt,npt,1,Scalar(255,255,255),lineType);

函数参数:

   1、多边形将被画到img上

   2、多边形的顶点集为ppt

   3、绘制的多边形顶点数目为npt

   4、要绘制的多边形数量为1

   5、多边形的颜色定义为Scarlar(255,255,255),即RGB的值为白色

	int lineType=0;

	//创建一些点
	  Point rookPoints[1][20];
	  rookPoints[0][0]  =Point(   WINDOW_SIZE/4,7*WINDOW_SIZE/8);
	  rookPoints[0][1]  =Point(   3*WINDOW_SIZE/4,7*WINDOW_SIZE/8);
	  rookPoints[0][2]  = Point(  3*WINDOW_SIZE/4,  13*WINDOW_SIZE/16 );
	  rookPoints[0][3]  = Point( 11*WINDOW_SIZE/16, 13*WINDOW_SIZE/16 );
	  rookPoints[0][4]  = Point( 19*WINDOW_SIZE/32,  3*WINDOW_SIZE/8 );
	  rookPoints[0][5]  = Point(  3*WINDOW_SIZE/4,   3*WINDOW_SIZE/8 );
	  rookPoints[0][6]  = Point(  3*WINDOW_SIZE/4,     WINDOW_SIZE/8 );
	  rookPoints[0][7]  = Point( 26*WINDOW_SIZE/40,    WINDOW_SIZE/8 );
	  rookPoints[0][8]  = Point( 26*WINDOW_SIZE/40,    WINDOW_SIZE/4 );
	  rookPoints[0][9]  = Point( 22*WINDOW_SIZE/40,    WINDOW_SIZE/4 );
	  rookPoints[0][10] = Point( 22*WINDOW_SIZE/40,    WINDOW_SIZE/8 );
	  rookPoints[0][11] = Point( 18*WINDOW_SIZE/40,    WINDOW_SIZE/8 );
	  rookPoints[0][12] = Point( 18*WINDOW_SIZE/40,    WINDOW_SIZE/4 );
	  rookPoints[0][13] = Point( 14*WINDOW_SIZE/40,    WINDOW_SIZE/4 );
	  rookPoints[0][14] = Point( 14*WINDOW_SIZE/40,    WINDOW_SIZE/8 );
	  rookPoints[0][15] = Point(    WINDOW_SIZE/4,     WINDOW_SIZE/8 );
	  rookPoints[0][16] = Point(    WINDOW_SIZE/4,   3*WINDOW_SIZE/8 );
	  rookPoints[0][17] = Point( 13*WINDOW_SIZE/32,  3*WINDOW_SIZE/8 );
	  rookPoints[0][18] = Point(  5*WINDOW_SIZE/16, 13*WINDOW_SIZE/16 );
	  rookPoints[0][19] = Point(    WINDOW_SIZE/4,  13*WINDOW_SIZE/16 );

	  const Point* ppt[1]={rookPoints[0]};
	  int npt[]={20};
	  fillPoly(img,
		  ppt,
		  npt,
		  1,
		  Scalar(255,255,255),
		  lineType);

你可能感兴趣的:(OpenCV)