绘制矩形和圆

 1 import cv2 as cv
 2 img = cv.imread('C:/Users/87823/Desktop/Aaron_Ecke.jpg')
 3 print(img.shape)
 4 # 左上角的坐标是(x,y),矩形的宽和高(w,h)
 5 x,y,w,h = 50,50,50,50
 6 cv.rectangle(img,(x,y,x+w,y+h),color=(0,255,0),thickness=3) #BGR
 7 # 绘制圆center元组指原点的坐标 radius:半径
 8 x,y,r = 100,100,80
 9 cv.circle(img,center=(x,y),radius=r,color=(0,0,255),thickness=3)
10 # 显示图片
11 cv.imshow('rectangle_img',img)
12 cv.waitKey(0)
13 cv.destroyAllWindows()

正是江南好风景
原文地址:https://www.cnblogs.com/monsterhy123/p/12924106.html