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