1st Leds try

This commit is contained in:
Nicolas Bertrand 2024-11-07 17:15:07 +01:00
parent a01c73d228
commit 7e3787053a
2 changed files with 14 additions and 5 deletions

6
requirements.txt Normal file
View File

@ -0,0 +1,6 @@
Flask
pillow
opencv-python
gphoto2
gpiozero
scipy

View File

@ -4,7 +4,7 @@ from os.path import join
import shutil
import time
import gphoto2 as gp
from gpiozero import PWMLED
from . import config
# Delay between to captures
@ -34,16 +34,19 @@ def capture(output_path: str) -> bool:
def scan(output_dir: str):
os.makedirs(output_dir, exist_ok=True)
for led in config.LEDS_UUIDS:
print(f'Turn on {led}')
gpio= PWMLED(17)
gpio.value = 0
for count,led in enumerate(config.LEDS_UUIDS):
print(f'Turn on {count} {led}')
img = join(output_dir, led + '.jpg')
# Measure the time it takes to capture
start = time.time()
gpio.value = count/len(config.LEDS_UUIDS)
capture(img)
# For debug purposes
#shutil.copyfile(join('data-keep/small', led + '.jpg'), img)
gpio.value = 0
delta = time.time() - start
@ -51,5 +54,5 @@ def scan(output_dir: str):
if delta < DELAY:
time.sleep(DELAY - delta)
print(f'Turn off {led}')
print(f'Turn off {count} {led}')
yield led