23 lines
478 B
Python
23 lines
478 B
Python
import cv2
|
|
import os
|
|
from os.path import join
|
|
from . import config
|
|
|
|
|
|
def capture(output_path: str) -> bool:
|
|
cam = cv2.VideoCapture(0)
|
|
s, img = cam.read()
|
|
if s:
|
|
cv2.imwrite(output_path, img)
|
|
cam.release()
|
|
return s
|
|
|
|
|
|
def scan(output_dir: str):
|
|
os.makedirs(output_dir, exist_ok=True)
|
|
for led in config.LEDS_UUIDS:
|
|
print(f'Turn on {led}')
|
|
img = join(output_dir, led + '.jpg')
|
|
capture(img)
|
|
print(f'Turn off {led}')
|