ComputerGraphicsStudyNotes0313 Week3 01
ComputerGraphicsStudyNotes0313 Week3 01
StudyNotes0313-Week3-01
1.1. Study Material
1.1.1. PDF file
opencv24-python-tutorials-readthedocs-io-en-stable.pdf
https://www.javatpoint.com/opencv
import cv2
import numpy as np
img = cv2.line(img,(50,50),(150,50),(255,255,0),5)
cv2.imshow('Draw Line',img)
cv2.waitKey(0)
cv2.destroyAllWindows() #Press Tab after 'de' will prompt full name of API
1.3.2. Drawing Rectangle
img = cv2.rectangle(img,(384,0),(510,128),(0,255,0),3)
import cv2
import numpy as np
#Create a black image
img = np.zeros((512,512,3), np.uint8)
#Draw a diagonal blue line with thickness of 5 px
img = cv2.rectangle(img,(50,50),(150,150),(0,255,0),3)
cv2.imshow('Draw Rectange',img)
cv2.waitKey(0)
cv2.destroyAllWindows() #Press Tab after 'de' will prompt full name of API
1.3.3. Drawing Circle
img = cv2.circle(img,(447,63), 63, (0,0,255), -1)
print(help(cv2.circle))
import cv2
import numpy as np
#Create a black image
img = np.zeros((512,512,3), np.uint8)
#Draw a diagonal blue line with thickness of 5 px
img = cv2.rectangle(img,(50,50),(150,150),(0,255,0),3)
img = cv2.circle(img,(100,100), 50, (0,0,255), -1)
cv2.imshow('Draw Rectange',img)
cv2.waitKey(0)
cv2.destroyAllWindows() #Press Tab after 'de' will prompt full name of API
pts = pts.reshape((-1,1,2))
img = cv2.polylines(img,[pts],True,(0,255,255))
1.3.6. Adding Text to Images
font = cv2.FONT_HERSHEY_SIMPLEX
1.4. No HomeWork