Guest User

Untitled

a guest
Dec 14th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. colors = [(255, 0, 0) , (255, 255, 0), (128, 255, 0), (0, 255, 0), (0, 255, 128), (0, 255, 255),
  2. (0, 128, 255), (0, 0, 255), (128, 0, 255), (255, 0, 255)]
  3. def draw_cv2(raw_strokes, size=256, lw=6):
  4. img = np.zeros((BASE_SIZE, BASE_SIZE,3), np.uint8)
  5. for t, stroke in enumerate(raw_strokes):
  6. for i in range(len(stroke[0]) - 1):
  7. color = colors[min(t, len(colors)-1)]
  8. _ = cv2.line(img, (stroke[0][i], stroke[1][i]), (stroke[0][i + 1], stroke[1][i + 1]),/
  9. color, lw, lineType=cv2.LINE_AA)
  10. if np.random.rand()>0.5:
  11. img = np.fliplr(img)
  12. if np.random.rand()>0.75:
  13. if np.random.rand()>0.50:
  14. img = img[ 4:, 4: ,:]
  15. else:
  16. img = img[ :-4, :-4 ,:]
  17. if np.random.rand()>0.50:
  18. img2 = cv2.resize(img, (200, 200))
  19. img = np.zeros((BASE_SIZE, BASE_SIZE,3), np.uint8)
  20. img[18:218,18:218, :] = img2
  21.  
  22. if size != BASE_SIZE:
  23. return cv2.resize(img, (size, size))
  24. else:
  25. return img
Add Comment
Please, Sign In to add comment