1
This commit is contained in:
Evan Pratten 2024-04-26 21:11:23 -04:00
parent acc14b9555
commit 063a531a0a

View File

@ -15,10 +15,12 @@ logger = logging.getLogger(__name__)
def normalize_brightness(frame, mode): def normalize_brightness(frame, mode):
if mode == "histogram": if mode == "hist-norm":
frame = cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX) frame = cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX)
frame = cv2.equalizeHist(frame) frame = cv2.equalizeHist(frame)
frame = cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX) frame = cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX)
elif mode == "hist":
frame = cv2.equalizeHist(frame)
elif mode == "basic": elif mode == "basic":
frame = cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX) frame = cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX)
return frame return frame
@ -36,7 +38,7 @@ def main() -> int:
"--camera", "--camera",
help="Which camera(s) to display", help="Which camera(s) to display",
choices=["left", "right", "both", "raw"], choices=["left", "right", "both", "raw"],
default="left", default="both",
) )
ap.add_argument( ap.add_argument(
"-l", "-l",
@ -49,8 +51,8 @@ def main() -> int:
"-b", "-b",
"--brightness-normalization", "--brightness-normalization",
help="Brightness normalization modes", help="Brightness normalization modes",
choices=["none", "histogram", "basic"], choices=["none", "hist", "hist-norm", "basic"],
default="histogram", default="hist",
) )
ap.add_argument("--record", help="Record the video to a file", action="store_true") ap.add_argument("--record", help="Record the video to a file", action="store_true")
ap.add_argument( ap.add_argument(
@ -212,7 +214,6 @@ def main() -> int:
video_frame = video_frame[:height, : width * 2] video_frame = video_frame[:height, : width * 2]
# Write the frame to the video # Write the frame to the video
cv2.imshow("Recording", video_frame)
video_output.write(video_frame) video_output.write(video_frame)
# If we need to do upscaling, do it now # If we need to do upscaling, do it now
@ -225,11 +226,16 @@ def main() -> int:
) )
# Show the frame # Show the frame
if args.camera in ["left", "both"]: if args.camera == "left":
cv2.imshow("Left", left_frame) cv2.imshow("Left", left_frame)
if args.camera in ["right", "both"]: if args.camera == "right":
cv2.imshow("Right", right_frame) cv2.imshow("Right", right_frame)
# If we need to show both cameras
if args.camera == "both":
frame = np.concatenate((left_frame, right_frame), axis=1)
cv2.imshow("Both", frame)
# Clean up # Clean up
cap.release() cap.release()
cv2.destroyAllWindows() cv2.destroyAllWindows()