1、cv2.line
import cv2
img = cv2.imread(r"img/1.jpg")
cv2.line(img, pt1=(100, 30), pt2=(210, 180), color=(0, 0, 255), thickness=2)
cv2.imshow("pic show", img)
cv2.waitKey(0)
2、cv2.circle:thickness=-1,内部填充
import cv2
img = cv2.imread(r"img/1.jpg")
cv2.circle(img, center=(50, 50), radius=30, color=(0, 0, 255), thickness=2)
cv2.imshow("pic show", img)
cv2.waitKey(0)
3、cv2.rectangle:thickness=-1,内部填充
cv2.rectangle(img, pt1=(100, 30), pt2=(210, 180), color=(0, 0, 255), thickness=2)
4、cv2.ellipse:thickness=-1,内部填充
cv2.ellipse(img, center=(100, 100), axes=(100, 50), angle=0, startAngle=0, endAngle=360, color=(255, 0, 0), thickness=-1)
5、cv2.polylines:[pts],否则点不连城线,thickness不能取负数
pts = np.array([[10, 5], [50, 10], [70, 20], [20, 30]], np.int32)
pts = pts.reshape((-1, 1, 2)) # shape[4, 1, 2]
cv2.polylines(img, [pts], isClosed=True, color=(0, 0, 255), thickness=2)
6、cv2.putText
# org:Bottom-left corner of the text string in the image
# lineType=cv2.LINE_AA:抗锯齿
cv2.putText(img, text='beautiful girl', org=(10, 30), fontFace=cv2.FONT_HERSHEY_SIMPLEX,
fontScale=1, color=(0, 0, 255), thickness=1, lineType=cv2.LINE_AA)