Draw a filled polygon using the OpenCV function fillPoly()
fillPoly() function of OpenCV is used to draw filled polygons like rectangle, triangle, pentagon over an image. This function takes inputs of an image and endpoints of Polygon and color.
- Image: This is image on which we want draw filled polygon
- End_Points: Points of polygon(for triangle 3 end points, for rectangle 4 end points will be there)
- Color: It specifies the color of polygon
Example 1: Draw a triangle
In this example we will draw filled polygon triangle by giving 3 endpoints such as [160,130],[350,130],[250,300] to fillPoly() function.
Example 2: Draw a Hexagon
In this example we will draw a hexagon by giving 6 endpoints such as [220,120],[130,200],[130,300],[220,380],[310,300],[310,200] to fillPoly() function.
Example 3: Draw a Rectangle
Sometimes there is a requirement that we need to show photos of someone by hiding their faces. In this case, we can use this function to hide the face of a person.
Please Login to comment...