Now, Lets draw small graphics using numpy and OpenCV
some of the function for this are
cv2.line(), cv2.circle() , cv2.rectangle(), cv2.ellipse(), cv2.putText()
As argument, you can give <img>,<color>,<thickness>,<lineType>
Where
<img> is the name of object
<color> is BGR tuple, eg: (255,0,0) for blue.
<thickness> is thickness of the graphic (-1 to fill, default = 1)
<lineType> is type of line, (eg. cv2.LINE_AA )
import numpy as np import cv2 # Create a black image img = np.zeros((512,512,3), np.uint8) # Draw a diagonal blue line with thickness of 5 px img = cv2.line(img,(0,0),(511,511),(0,0,255),5) cv2.imshow('image',img) cv2.waitKey(0) cv2.destroyAllWindows()
Please note that OpenCV is using BGR
Now, try
img = cv2.rectangle(img,(384,0),(510,128),(0,255,0),3 img = cv2.circle(img,(447,63), 63, (0,0,255), -1) img = cv2.ellipse(img,(256,256),(100,50),0,0,180,255,-1)
font = cv2.FONT_HERSHEY_SIMPLEX cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2,cv2.LINE_AA)