Set exposure in the main loop and at every frame
This commit is contained in:
parent
0c4992ffaf
commit
f1678de324
2 changed files with 20 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue