From 799628eddf64a5264b7d76ac2eb263990dbd3f59 Mon Sep 17 00:00:00 2001 From: Peter-Simon Dieterich Date: Fri, 1 Nov 2019 11:53:17 +0100 Subject: [PATCH] Apply CLAHE to frames in add.py and compare.py --- src/cli/add.py | 3 +++ src/compare.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/cli/add.py b/src/cli/add.py index 3106055..44b4480 100644 --- a/src/cli/add.py +++ b/src/cli/add.py @@ -139,12 +139,15 @@ enc = [] frames = 0 dark_threshold = config.getfloat("video", "dark_threshold") +clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)) + # Loop through frames till we hit a timeout while frames < 60: # Grab a single frame of video # Don't remove ret, it doesn't work without it ret, frame = video_capture.read() gsframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + gsframe = clahe.apply(gsframe) # Create a histogram of the image with 8 values hist = cv2.calcHist([gsframe], [0], None, [8], [0, 256]) diff --git a/src/compare.py b/src/compare.py index 98c6b72..228f227 100644 --- a/src/compare.py +++ b/src/compare.py @@ -172,6 +172,8 @@ end_report = config.getboolean("debug", "end_report") frames = 0 timings["fr"] = time.time() +clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)) + while True: # Increment the frame count every loop frames += 1 @@ -197,6 +199,8 @@ while True: print("\nUnknown camera, please check your 'device_path' config value.\n") raise + gsframe = clahe.apply(gsframe) + # Create a histogram of the image with 8 values hist = cv2.calcHist([gsframe], [0], None, [8], [0, 256]) # All values combined for percentage calculation