Skip to content

Instantly share code, notes, and snippets.

@yokeshrana
Created March 8, 2021 09:32
Show Gist options
  • Save yokeshrana/dabc90599d25e67ed336823a214537b4 to your computer and use it in GitHub Desktop.
Save yokeshrana/dabc90599d25e67ed336823a214537b4 to your computer and use it in GitHub Desktop.
Draw Lines ,text ,Rectangle and circle
import cv2
import numpy as np
img = np.zeros((512,512)) # gray scale image (can check by shape also )
# To add the color make it 3 channel
img = np.zeros((512,512,3))
#img[:]=255,0,0
'''
To Draw the line ,Rectange ,Circle and put text on images
'''
cv2.line(img,(0,0),(300,300),(0,255,0),3) # start point ,end point and thickness
cv2.rectangle(img,(0,0),(250,350),(0,0,255),4) # start point ,end point and thickness(or can fill also fuly)
cv2.circle(img,(400,50),30,(255,255,0),5) #center point,radius ,color and thickness
cv2.putText(img,"OPENCV",(300,300),cv2.FONT_HERSHEY_DUPLEX,1,(0,255,0),3)
cv2.imshow("Image", img)
cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment