How to Draw Different Shapes in OpenCV
Machine Learning courses with 100+ Real-time projects Start Now!!
Program 1
import cv2
import numpy as np
emptyimg=np.zeros((700,700,3))
#emptyimg[200:300,300:400]=255,0,0
# Draw Rectangle
#cv2.rectangle(emptyimg,(50,50),(300,300),(0,0,255),thickness=cv2.FILLED)
# print(emptyimg.shape[1]//2)
# print(emptyimg.shape[0]//2)
#cv2.rectangle(emptyimg,(30,30),(emptyimg.shape[1]//2,emptyimg.shape[0]//2),(255,255,0),thickness=cv2.FILLED)
#Draw circle
# cv2.circle(emptyimg,(100,100),70,(0,0,255),thickness=cv2.FILLED)
# cv2.imshow('Blank Window',emptyimg)
#Draw circle
# cv2.line(emptyimg,(0,0),(300,300),(0,255,0),thickness=3)
# cv2.line(emptyimg,(500,0),(0,500),(0,255,0),thickness=7)
cv2.rectangle(emptyimg,(50,50),(650,150),(0,255,255),thickness=1)
cv2.putText(emptyimg,"Data Flair OpenCV",(50,100),cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,2.0,(255,0,255),thickness=None)
cv2.imshow('Blank Window',emptyimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

