From 59351bba6cc85a32af447e163cbb4c9922b1cd25 Mon Sep 17 00:00:00 2001 From: Aryan Date: Tue, 10 Oct 2023 23:56:33 +0530 Subject: [PATCH 1/2] reduced noises in input image from webcam using median and gaussian blur --- run_webcam.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/run_webcam.py b/run_webcam.py index 0292759..deb28af 100644 --- a/run_webcam.py +++ b/run_webcam.py @@ -51,9 +51,19 @@ def main(): fps = video.FPS().start() while True: - ret, frame = cap.read() + ret, frame1 = cap.read() # resize image and detect face + + # removing noises from the extracted frame using median Blur + frame_1 = cv2.medianBlur(frame1 , 5) + + # amplifying the edges using gaussian blur + frame_2 = cv2.GaussianBlur(src= frame1 , ksize = (5,5) , sigmaX = 0) + + # combining the results of both the blurs + frame = cv2.addWeighted(frame1 , 0.6 , frame_2 , 0.5 , 0) + frame_resize = cv2.resize(frame, None, fx=1 / DOWNSAMPLE_RATIO, fy=1 / DOWNSAMPLE_RATIO) gray = cv2.cvtColor(frame_resize, cv2.COLOR_BGR2GRAY) faces = detector(gray, 1) From 2390601e4d150bd6cdda11717b894cc82757ac16 Mon Sep 17 00:00:00 2001 From: Aryan Date: Tue, 10 Oct 2023 23:59:21 +0530 Subject: [PATCH 2/2] changed frame --- run_webcam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_webcam.py b/run_webcam.py index deb28af..f68041b 100644 --- a/run_webcam.py +++ b/run_webcam.py @@ -62,7 +62,7 @@ def main(): frame_2 = cv2.GaussianBlur(src= frame1 , ksize = (5,5) , sigmaX = 0) # combining the results of both the blurs - frame = cv2.addWeighted(frame1 , 0.6 , frame_2 , 0.5 , 0) + frame = cv2.addWeighted(frame_1 , 0.6 , frame_2 , 0.5 , 0) frame_resize = cv2.resize(frame, None, fx=1 / DOWNSAMPLE_RATIO, fy=1 / DOWNSAMPLE_RATIO) gray = cv2.cvtColor(frame_resize, cv2.COLOR_BGR2GRAY)