Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import cv2
- img = np.zeros((256,256,3), np.uint8)
- # круг
- cv2.rectangle(img,(0,0),(128,128),(0,255,0),-1)
- cv2.circle(img,(64,64), 45, (0,0,255), -1)
- # квадрат
- cv2.rectangle(img,(128,0),(256,128),(255,0,0),-1)
- cv2.rectangle(img,(160,32),(224,96),(255,255,255),-1)
- #треугольник
- cv2.rectangle(img,(0,126),(128,256),(255,255,255),-1)
- # cv2.line(img,(64,142),(112,240),(0,0,0),4)
- # cv2.line(img,(16, 240),(64,142),(0,0,0),4)
- # cv2.line(img,(16, 240),(112,240),(0,0,0),4)
- pts = np.array([[64,142],[112,240],[16, 240]], np.int32)
- color_black = [0, 0, 0]
- # pts = pts.reshape((-1,1,2))
- # cv2.polylines(img,[pts],True,(0, 0, 0))
- cv2.fillPoly(img, pts, color_black)
- img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- cv2.imshow("Image", img)
- cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement