绘制矩形和圆

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

 

posted @ 2020-05-20 15:55  小他_W  阅读(197)  评论(0编辑  收藏  举报