函數說明如下:
函數原型:void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0) 函數作用:填充凸多邊形 參數說明:img 圖像 pts 指向單個多邊形的指針數組 npts 多邊形的頂點個數 color 多邊形的顏色 LineType 組成多邊形的線條的類型 8 (or 0) - 8-connected line(8鄰接)連接 線。 4 - 4-connected line(4鄰接)連接線。 CV_AA - antialiased 線條。 shift 頂點坐標的小數點位數
函數說明:函數fillConvexPoly填充凸多邊形內部。這個函數比函數cvFillPoly 更快。它除了可以填充凸多邊形區域還可以填充任何的單調多邊形。例如:一個被水平線(掃描線)至多兩次截斷的多邊形
舉例說明:
1 int _tmain(int argc, char** argv) 2 { 3 Point PointArray[4]; 4 Mat src = Mat::zeros(480,640,CV_8UC3); 5 6 src.setTo(255); 7 8 PointArray[0] = Point(50,10); 9 PointArray[1] = Point(300,12); 10 PointArray[2] = Point(350,250); 11 PointArray[3] = Point(9,250); 12 13 cv::fillConvexPoly(src,PointArray,4,Scalar(0,0,0)); 14 imshow("1",src); 15 waitKey(0); 16 17 return 0; 18 }
結果如下: