#!/usr/bin/python from simplecv.api import Color, Image from simplecv.core.drawing.layer import DrawingLayer img = Image("color.jpg", sample=True) line_l = DrawingLayer() a = (20, 20) b = (20, 100) c = (100, 100) d = (100, 20) line_l.line(a, b, alpha=128, width=5) line_l.line(b, c, alpha=128) line_l.line(c, d, antialias=True) line_l.line(d, a, color=Color.PUCE) line_l.line(b, d, width=5) img.add_drawing_layer(line_l) temp = img.apply_layers() print "line: %s" % temp.save(temp=True) img.clear_layers() lines_l = DrawingLayer() a = (20, 20) b = (20, 100) c = (100, 100) d = (100, 20) pts = (a, b, c, d, a) lines_l.lines(pts, alpha=128) # translate over and down 10 pts = map(lambda x: ((x[0] + 10), (x[1] + 10)), pts) lines_l.lines(pts, color=Color.BEIGE, width=10) #translate over and down 10
# write the text layer.text("Just some innocent looking dots", (50, 25), Color.BLACK) layer.text("Use w/s keys to change intensity", (50, 50), Color.BLACK) layer.text("a/d keys to change angle", (50, 75), Color.BLACK) #draw 6 innocent looking dots layer.circle((125, 200), 25, Color.RED, 1, True) layer.circle((250, 200), 25, Color.BLUE, 1, True) layer.circle((375, 200), 25, Color.GREEN, 1, True) layer.circle((125, 300), 25, Color.YELLOW, 1, True) layer.circle((250, 300), 25, Color.ORANGE, 1, True) layer.circle((375, 300), 25, Color.CYAN, 1, True) # apply layer img.add_drawing_layer(layer) img = img.apply_layers() img.show() power = 1 angle = 0 while True: key = cv2.waitKey(1) if key == -1: continue print chr(key) # detect w,a,s,d key presses and modify power, angle if key == ord('w'): power += 10 blur = img.motion_blur2(power, angle)