赞
踩
cv2.rectangle(img, pt1, pt2, color, thickness=None, lineType=None, shift=None )
以下来自官方文档和自己的理解
- import cv2 as cv
-
- image = np.zeros((512,512,3),dtype=np.uint8)
-
- cv.rectangle(image, (200,200), (0,0), (0,0,255), 1, cv.LINE_8, 3)#红
- cv.rectangle(image, (200,200), (0,0), (0,255,0), 1, cv.LINE_8, 2)#绿
- cv.rectangle(image, (200,200), (0,0), (255,0,0), 1, cv.LINE_8, 1)#蓝
- cv.rectangle(image, (200,200), (0,0), (0,255,255), 1, cv.LINE_8, 0)#黄
-
- cv.imshow("image", image)
- cv.waitKey(0)
- cv.destroyAllWindows()
- import cv2 as cv
-
- image = np.zeros((512,512,3),dtype=np.uint8)
-
- cv.rectangle(image, (200,200), (100,100), (0,0,255), 1, cv.LINE_8, 3)
- cv.rectangle(image, (200,200), (100,100), (0,255,0), 1, cv.LINE_8, 2)
- cv.rectangle(image, (200,200), (100,100), (255,0,0), 1, cv.LINE_8, 1)
- cv.rectangle(image, (200,200), (100,100), (0,255,255), 1, cv.LINE_8, 0)
-
- cv.imshow("image", image)
- cv.waitKey(0)
- cv.destroyAllWindows()
两个角点分别为(200,200),(100,0)
- import cv2 as cv
-
- image = np.zeros((512,512,3),dtype=np.uint8)
-
- cv.rectangle(image, (200,200), (100,0), (0,0,255), 1, cv.LINE_8, 3)
- cv.rectangle(image, (200,200), (100,0), (0,255,0), 1, cv.LINE_8, 2)
- cv.rectangle(image, (200,200), (100,0), (255,0,0), 1, cv.LINE_8, 1)
- cv.rectangle(image, (200,200), (100,0), (0,255,255), 1, cv.LINE_8, 0)
-
- cv.imshow("image", image)
- cv.waitKey(0)
- cv.destroyAllWindows()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。