1st Leds try
This commit is contained in:
parent
a01c73d228
commit
7e3787053a
|
|
@ -0,0 +1,6 @@
|
||||||
|
Flask
|
||||||
|
pillow
|
||||||
|
opencv-python
|
||||||
|
gphoto2
|
||||||
|
gpiozero
|
||||||
|
scipy
|
||||||
13
scanner.py
13
scanner.py
|
|
@ -4,7 +4,7 @@ from os.path import join
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
import gphoto2 as gp
|
import gphoto2 as gp
|
||||||
|
from gpiozero import PWMLED
|
||||||
from . import config
|
from . import config
|
||||||
|
|
||||||
# Delay between to captures
|
# Delay between to captures
|
||||||
|
|
@ -34,16 +34,19 @@ def capture(output_path: str) -> bool:
|
||||||
|
|
||||||
def scan(output_dir: str):
|
def scan(output_dir: str):
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
for led in config.LEDS_UUIDS:
|
gpio= PWMLED(17)
|
||||||
print(f'Turn on {led}')
|
gpio.value = 0
|
||||||
|
for count,led in enumerate(config.LEDS_UUIDS):
|
||||||
|
print(f'Turn on {count} {led}')
|
||||||
img = join(output_dir, led + '.jpg')
|
img = join(output_dir, led + '.jpg')
|
||||||
|
|
||||||
# Measure the time it takes to capture
|
# Measure the time it takes to capture
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
gpio.value = count/len(config.LEDS_UUIDS)
|
||||||
capture(img)
|
capture(img)
|
||||||
# For debug purposes
|
# For debug purposes
|
||||||
#shutil.copyfile(join('data-keep/small', led + '.jpg'), img)
|
#shutil.copyfile(join('data-keep/small', led + '.jpg'), img)
|
||||||
|
gpio.value = 0
|
||||||
|
|
||||||
delta = time.time() - start
|
delta = time.time() - start
|
||||||
|
|
||||||
|
|
@ -51,5 +54,5 @@ def scan(output_dir: str):
|
||||||
if delta < DELAY:
|
if delta < DELAY:
|
||||||
time.sleep(DELAY - delta)
|
time.sleep(DELAY - delta)
|
||||||
|
|
||||||
print(f'Turn off {led}')
|
print(f'Turn off {count} {led}')
|
||||||
yield led
|
yield led
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue