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()