-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (43 loc) · 1.39 KB
/
main.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
import os
import sys
from itertools import cycle
import cv2 as cv
import numpy as np
import alp42
from alp42 import (
Device, ControlType, InquireType, ControlValue,
Sequence, SequenceControl, SequenceValue
)
os.add_dll_directory("C:/Program Files/Teledyne/Spinnaker/bin64/vs2015")
import camera
dev = Device(0, 0)
camera.start()
print(dev[InquireType.DeviceNumber])
print(dev[InquireType.DevDMDType])
print(dev[InquireType.AvailableMemory])
width = dev.width
height = dev.height
x0, x1 = 235, 660
y0, y1 = 133, 558
cell = 85
seqs = []
img = np.ones((1, height, width), dtype=np.uint8)
for i in range((y1 - y0) // cell):
for j in range((x1 - x0) // cell):
pattern = np.ones((y1 - y0, x1 - x0), dtype=np.uint8)
pattern[cell * i:cell * (i + 1), cell * j:cell * (j + 1)] = 0
img[0, x0:x1, y0:y1] = pattern
seq = dev.make_sequence(bit_planes=1, pic_num=1)
seq[SequenceControl.DataFormat] = SequenceValue.DataLSB
seq.put(img.data)
seq.timing(picture_time=10000)
seqs.append(seq)
for i, seq in enumerate(cycle(seqs)):
alp42.start_projection(seq, cont=True)
if i < len(seqs):
camera.take_picture(f"imgs/pixel_size {cell};row {i // ((y1 - y0) // cell) + 1};column {i % ((y1 - y0) // cell) + 1}.png")
else:
command = input()
if command.startswith('q'):
break
print("\033[A\033[0K", end='')