cv2.rectangle()函数用于在图像上绘制矩形。它接受以下参数:
示例代码:
import cv2
img = cv2.imread('image.jpg')
pt1 = (50, 50)
pt2 = (200, 200)
color = (255, 0, 0)
thickness = 2
cv2.rectangle(img, pt1, pt2, color, thickness)
cv2.imshow('Image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>