DELAY, cleaning
This commit is contained in:
parent
01f59f55f2
commit
9eb3c6af0b
|
|
@ -7,7 +7,7 @@ OBJECT_DIR = join(DATA_DIR, 'objects')
|
|||
DATABASE_PATH = join(DATA_DIR, 'db.sqlite')
|
||||
|
||||
AUTO_USE_LAST_CALIBRATION = True
|
||||
DELAY = 0.0
|
||||
DELAY = None
|
||||
GPIO_CHIP = 'gpiochip0'
|
||||
LEDS_UUIDS = [17, 18, 22, 23, 24, 27]
|
||||
CAMERA = 'real'
|
||||
|
|
|
|||
21
scanner.py
21
scanner.py
|
|
@ -11,7 +11,21 @@ def delay_capture(cam):
|
|||
delta = time.time() - start
|
||||
|
||||
# Wait for at least one second between each capture
|
||||
if delta < config.DELAY:
|
||||
if config.DELAY is not None and delta < config.DELAY:
|
||||
time.sleep(config.DELAY - delta)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def delay_save(cam, source, target):
|
||||
# Measure the time it takes to save
|
||||
start = time.time()
|
||||
output = cam.capture()
|
||||
cam.save(source, target)
|
||||
delta = time.time() - start
|
||||
|
||||
# Wait for at least one second between each save
|
||||
if config.DELAY is not None and delta < config.DELAY:
|
||||
time.sleep(config.DELAY - delta)
|
||||
|
||||
return output
|
||||
|
|
@ -25,7 +39,6 @@ def scan(output_dir: str, on_and_off: bool = True):
|
|||
with leds.get() as gpio_leds:
|
||||
for count, led in enumerate(gpio_leds.leds):
|
||||
print(f'Turn on {led}')
|
||||
img = join(output_dir, f'{led}')
|
||||
|
||||
led.on()
|
||||
file_paths.append((str(led), delay_capture(cam)))
|
||||
|
|
@ -36,14 +49,12 @@ def scan(output_dir: str, on_and_off: bool = True):
|
|||
# capture with all leds ON OFF
|
||||
if on_and_off:
|
||||
gpio_leds.on()
|
||||
img = join(output_dir, 'all_on')
|
||||
file_paths.append(('all_on', delay_capture(cam)))
|
||||
|
||||
gpio_leds.off()
|
||||
img = join(output_dir, 'all_off')
|
||||
file_paths.append(('all_off', delay_capture(cam)))
|
||||
|
||||
with camera.get() as cam:
|
||||
for target, source in file_paths:
|
||||
cam.save(source, join(output_dir, target))
|
||||
delay_save(cam, source, join(output_dir, target))
|
||||
yield target
|
||||
|
|
|
|||
Loading…
Reference in New Issue