diff --git a/src/cli/test.py b/src/cli/test.py index 346e465..b748140 100644 --- a/src/cli/test.py +++ b/src/cli/test.py @@ -37,16 +37,8 @@ if fw != -1: if fh != -1: video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, fh) -# Disable autoexposure +# Read exposure from config to use in the main loop exposure = config.getint("video", "exposure", fallback=-1) -if exposure != -1: - # For a strange reason on some cameras (e.g. Lenoxo X1E) - # setting manual exposure works only after a couple frames - # are captured. - for i in range(6): - video_capture.grab() - video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual - video_capture.set(cv2.CAP_PROP_EXPOSURE, 167.0) # Let the user know what's up print(""" @@ -204,6 +196,15 @@ try: if slow_mode: time.sleep(.5 - frame_time) + if exposure != -1: + # For a strange reason on some cameras (e.g. Lenoxo X1E) + # setting manual exposure works only after a couple frames + # are captured and even after a delay it does not + # always work. Setting exposure at every frame is + # reliable though. + video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual + video_capture.set(cv2.CAP_PROP_EXPOSURE, float(exposure)) + # On ctrl+C except KeyboardInterrupt: # Let the user know we're stopping diff --git a/src/compare.py b/src/compare.py index 97d1027..17ac2a7 100644 --- a/src/compare.py +++ b/src/compare.py @@ -144,16 +144,8 @@ if fh != -1: # This will let the camera adjust its light levels while we're importing for faster scanning video_capture.grab() -# Disable autoexposure +# Read exposure from config to use in the main loop exposure = config.getint("video", "exposure", fallback=-1) -if exposure != -1: - # For a strange reason on some cameras (e.g. Lenoxo X1E) - # setting manual exposure works only after a couple frames - # are captured. - for i in range(5): - video_capture.grab() - video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual - video_capture.set(cv2.CAP_PROP_EXPOSURE, 167.0) # Note the time it took to open the camera timings["ic"] = time.time() - timings["ic"] @@ -272,3 +264,12 @@ while True: # End peacefully stop(0) + + if exposure != -1: + # For a strange reason on some cameras (e.g. Lenoxo X1E) + # setting manual exposure works only after a couple frames + # are captured and even after a delay it does not + # always work. Setting exposure at every frame is + # reliable though. + video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual + video_capture.set(cv2.CAP_PROP_EXPOSURE, float(exposure))