-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaperture_sandbox.py
70 lines (48 loc) · 1.43 KB
/
aperture_sandbox.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import cv2
import numpy as np
cv2.rotate
def grating(canvas, angle, spacing, step=0):
frame = np.zeros_like(canvas, dtype=np.uint8)
pt1 = [step,0]
pt2 = [step,height]
reps = canvas.shape[0] // spacing
for ii in range(reps):
cv2.line(frame, pt1, pt2, (1,1,1), 1)
pt1[0] += spacing
pt2[0] += spacing
#cv2.rotate()
return frame
height = 512
width = 512
origin = [height//2, width//2]
canvas = np.zeros([height, width], dtype=np.uint8)
mask = cv2.circle(canvas.copy(), origin, 200, (1,1,1), -1)
line_one_top = [0,0]
line_one_btm = [width,height]
line_two_top = [0,height]
line_two_btm = [width,0]
step = 5
#Make a function to add an arbitrary line/offset
while True:
frame = grating(canvas, angle=10, spacing=10, step=step)
step += 1
# frame = canvas.copy()
# cv2.line(frame, line_one_top, line_one_btm, (255,255,255), 3)
# cv2.line(frame, line_two_top, line_two_btm, (255,255,255), 3)
frame *= mask
if step >= 10:
step = 0
# line_one_top[0] += step
# line_one_btm[0] += step
# line_two_top[0] += step
# line_two_btm[0] += step
# if line_one_top[0] >= width:
# line_one_top = [-width,0]
# line_one_btm = [0,height]
# line_two_top = [-width,height]
# line_two_btm = [0,0]
cv2.imshow("Aperture", frame*255)
key = cv2.waitKey(16)
if key == ord('q'):
break
cv2.destroyAllWindows