Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3.  
  4. img = np.zeros((256,256,3), np.uint8)
  5.  
  6. # круг
  7. cv2.rectangle(img,(0,0),(128,128),(0,255,0),-1)
  8. cv2.circle(img,(64,64), 45, (0,0,255), -1)
  9.  
  10. # квадрат
  11. cv2.rectangle(img,(128,0),(256,128),(255,0,0),-1)
  12. cv2.rectangle(img,(160,32),(224,96),(255,255,255),-1)
  13.  
  14. #треугольник
  15. cv2.rectangle(img,(0,126),(128,256),(255,255,255),-1)
  16. # cv2.line(img,(64,142),(112,240),(0,0,0),4)
  17. # cv2.line(img,(16, 240),(64,142),(0,0,0),4)
  18. # cv2.line(img,(16, 240),(112,240),(0,0,0),4)
  19.  
  20.  
  21. pts = np.array([[64,142],[112,240],[16, 240]], np.int32)
  22. color_black = [0, 0, 0]
  23. # pts = pts.reshape((-1,1,2))
  24. # cv2.polylines(img,[pts],True,(0, 0, 0))
  25. cv2.fillPoly(img, pts, color_black)
  26.  
  27. img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  28.  
  29. cv2.imshow("Image", img)
  30. cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement