improve contrast

This commit is contained in:
Blake Blackshear 2021-11-04 11:01:12 -05:00
parent 8ab6cba521
commit 08ddfc100f

View File

@ -36,7 +36,13 @@ class MotionDetector:
interpolation=cv2.INTER_LINEAR, interpolation=cv2.INTER_LINEAR,
) )
# TODO: can I improve the contrast of the grayscale image here? # Improve contrast
minval = np.percentile(resized_frame, 5)
maxval = np.percentile(resized_frame, 95)
resized_frame = np.clip(resized_frame, minval, maxval)
resized_frame = (((resized_frame - minval) / (maxval - minval)) * 255).astype(
np.uint8
)
# convert to grayscale # convert to grayscale
# resized_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2GRAY) # resized_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2GRAY)