- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Draw a filled polygon using the OpenCV function fillPoly()
In this program, we will draw a filled polygon using the opencv function fillPoly(). The function takes in an image and the endpoints of the polygon.
Algorithm
Step 1: Import cv2 and numpy. Step 2: Define the endpoints. Step 3: Define the image using zeros. Step 4: Draw the polygon using the fillpoly() function. Step 5: Display the output.
Example Code
import cv2 import numpy as np contours = np.array([[50,50], [50,150], [150,150], [150,50]]) image = np.zeros((200,200)) cv2.fillPoly(image, pts = [contours], color =(255,255,255)) cv2.imshow("filledPolygon", image)
Output
- Related Articles
- How to draw a filled polygon in OpenCV using Java?
- How to draw a filled polygon using an imagefilledpolygon() function in PHP?
- How to draw a polygon in OpenCV using Java?
- How to draw a filled circle in OpenCV using Java?
- How to draw a filled ellipse in OpenCV using Java?
- How to draw filled ellipses in OpenCV using Python?
- Draw a circle using OpenCV function circle()
- fillpoly() function in C
- How to draw an open polygon using the imageopenpolygon() function n PHP?
- How to draw a hexagon with Polygon using FabricJS?
- Draw a line on an image using OpenCV
- How to draw a rectangle with Polygon object using FabricJS?
- How to draw a line in OpenCV using Java?
- How to draw a rectangle in OpenCV using Java?
- How to draw a circle in OpenCV using Java?

Advertisements