使用 OpenCV 函数 fillPoly() 绘制一个填充多边形
在本程序中,我们将使用 opencv 函数 fillPoly() 绘制一个填充多边形。该函数需要图像和多边形的端点。
算法
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.
示例代码
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)输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP