1

Add LED control

This commit is contained in:
Evan Pratten 2024-04-25 20:14:44 -04:00
parent 58ebddcb9c
commit 4ff2aff17d

View File

@ -8,6 +8,7 @@ import numpy as np
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def main() -> int: def main() -> int:
# Handle program arguments # Handle program arguments
ap = argparse.ArgumentParser( ap = argparse.ArgumentParser(
@ -22,8 +23,15 @@ def main() -> int:
choices=["640x120", "640x240", "640x480", "752x120", "752x240", "752x480"], choices=["640x120", "640x240", "640x480", "752x120", "752x240", "752x480"],
default="640x480", default="640x480",
) )
ap.add_argument("--only", help="Only show the left or right camera", choices=["left", "right"]) ap.add_argument(
ap.add_argument("--no-brightness-normalization", help="Do not normalize the brightness of the frames", action="store_true") "--only", help="Only show the left or right camera", choices=["left", "right"]
)
ap.add_argument("--no-led", help="Disable the LEDs", action="store_true")
ap.add_argument(
"--no-brightness-normalization",
help="Do not normalize the brightness of the frames",
action="store_true",
)
ap.add_argument( ap.add_argument(
"-v", "--verbose", help="Enable verbose logging", action="store_true" "-v", "--verbose", help="Enable verbose logging", action="store_true"
) )
@ -48,6 +56,13 @@ def main() -> int:
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
cap.set(cv2.CAP_PROP_CONVERT_RGB, 0) cap.set(cv2.CAP_PROP_CONVERT_RGB, 0)
# Configure the LEDs
# NOTE: See the libuvc for leap documentation for info about this
# https://github.com/ewpratten/leapuvc/blob/master/LeapUVC-Manual.pdf
cap.set(cv2.CAP_PROP_CONTRAST, (0b0010 | (int(not args.no_led) << 6)))
cap.set(cv2.CAP_PROP_CONTRAST, (3 | (int(not args.no_led) << 6)))
cap.set(cv2.CAP_PROP_CONTRAST, (4 | (int(not args.no_led) << 6)))
# Read frames # Read frames
while True: while True:
ret, frame = cap.read() ret, frame = cap.read()