Skip to content

Instantly share code, notes, and snippets.

@8dcc
Last active July 18, 2021 03:31
Show Gist options
  • Save 8dcc/86a7904fabe11695b7f326654e2c555b to your computer and use it in GitHub Desktop.
Save 8dcc/86a7904fabe11695b7f326654e2c555b to your computer and use it in GitHub Desktop.
Python OpenCV cheatsheet

OpenCV cheatsheet

I am still learning opencv, so I will add here stuff when I use it. Mostly made for personal use.

Other shapes:

cv2.line(img,(200,200),(611,511),(10,10,255),3)  # Line
cv2.rectangle(img,(19,22),(576,579),(0,255,0),2)  # Rectangle
cv2.circle(img,(447,63), 63, (0,0,255), -1)  # Circle
cv2.ellipse(img,(256,256),(100,50),0,0,180,255,-1)  # Ellipse

font = cv2.FONT_HERSHEY_PLAIN  # See https://gist.github.com/r4v10l1/86a7904fabe11695b7f326654e2c555b#fonts
cv2.putText(img,'r4v10l1 rocks!',(200,18), font, 3,(100,100,100),2,cv2.LINE_AA)

Fonts:

FONT_HERSHEY_SIMPLEX 
FONT_HERSHEY_PLAIN 
FONT_HERSHEY_DUPLEX 
FONT_HERSHEY_COMPLEX 
FONT_HERSHEY_TRIPLEX 
FONT_HERSHEY_COMPLEX_SMALL 
FONT_HERSHEY_SCRIPT_SIMPLEX 
FONT_HERSHEY_SCRIPT_COMPLEX 
FONT_ITALIC 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment