1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import cv2 as cv import numpy as np
blank = np.zeros((500,500,3), dtype='uint8') cv.imshow('Blank', blank)
blank[200:300, 300:400] = 0,0,255 cv.imshow('Green', blank)
cv.rectangle(blank, (0,0), (blank.shape[1]//2, blank.shape[0]//2), (0,255,0), thickness=-1) cv.imshow('Rectangle', blank)
cv.circle(blank, (blank.shape[1]//2, blank.shape[0]//2), 40, (0,0,255), thickness=-1) cv.imshow('Circle', blank)
cv.line(blank, (100,250), (300,400), (255,255,255), thickness=3) cv.imshow('Line', blank)
cv.putText(blank, 'Hello World!', (0,225), cv.FONT_HERSHEY_TRIPLEX, 1.0, (0,255,0), 2) cv.imshow('Text', blank)
cv.waitKey(0)
|