Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- colors = [(255, 0, 0) , (255, 255, 0), (128, 255, 0), (0, 255, 0), (0, 255, 128), (0, 255, 255),
- (0, 128, 255), (0, 0, 255), (128, 0, 255), (255, 0, 255)]
- def draw_cv2(raw_strokes, size=256, lw=6):
- img = np.zeros((BASE_SIZE, BASE_SIZE,3), np.uint8)
- for t, stroke in enumerate(raw_strokes):
- for i in range(len(stroke[0]) - 1):
- color = colors[min(t, len(colors)-1)]
- _ = cv2.line(img, (stroke[0][i], stroke[1][i]), (stroke[0][i + 1], stroke[1][i + 1]),/
- color, lw, lineType=cv2.LINE_AA)
- if np.random.rand()>0.5:
- img = np.fliplr(img)
- if np.random.rand()>0.75:
- if np.random.rand()>0.50:
- img = img[ 4:, 4: ,:]
- else:
- img = img[ :-4, :-4 ,:]
- if np.random.rand()>0.50:
- img2 = cv2.resize(img, (200, 200))
- img = np.zeros((BASE_SIZE, BASE_SIZE,3), np.uint8)
- img[18:218,18:218, :] = img2
- if size != BASE_SIZE:
- return cv2.resize(img, (size, size))
- else:
- return img
Add Comment
Please, Sign In to add comment