From 58ebddcb9c42dec2f20515e12f19645ba8002756 Mon Sep 17 00:00:00 2001 From: Evan Pratten <evan@ewpratten.com> Date: Thu, 25 Apr 2024 15:39:12 -0400 Subject: [PATCH] Improve brightness alg --- scripts/leap-view | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/leap-view b/scripts/leap-view index 27b3e06..2cecbd1 100755 --- a/scripts/leap-view +++ b/scripts/leap-view @@ -8,7 +8,6 @@ import numpy as np logger = logging.getLogger(__name__) - def main() -> int: # Handle program arguments ap = argparse.ArgumentParser( @@ -24,6 +23,7 @@ def main() -> int: default="640x480", ) ap.add_argument("--only", help="Only show the left or right camera", choices=["left", "right"]) + ap.add_argument("--no-brightness-normalization", help="Do not normalize the brightness of the frames", action="store_true") ap.add_argument( "-v", "--verbose", help="Enable verbose logging", action="store_true" ) @@ -62,6 +62,15 @@ def main() -> int: # Split into left and right frames (every other byte) left_frame = frame[:, 0::2] right_frame = frame[:, 1::2] + + # Ignore the last row of the frames + left_frame = left_frame[:-1] + right_frame = right_frame[:-1] + + # Normalize the frames so that the brightest pixel is 255 + if not args.no_brightness_normalization: + left_frame = cv2.normalize(left_frame, None, 0, 255, cv2.NORM_MINMAX) + right_frame = cv2.normalize(right_frame, None, 0, 255, cv2.NORM_MINMAX) # Show the frame if not args.only or args.only == "left":