commit 6d26ac322a5e38334e4ca45c6d2277edf6e9e656
parent 22bcc0437435015a836cade79c84d48665caa77f
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Sat, 8 Aug 2020 19:22:07 +0200
Add filter to reduce noise
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/faldet.py b/faldet.py
@@ -10,6 +10,10 @@ while(True):
fgmask = bgsub.apply(frame)
+ # apply some filter to smoothen things out
+ blur = cv2.GaussianBlur(fgmask, (5, 5), 0)
+ avg = cv2.threshold(blur, 60, 255, cv2.THRESH_BINARY)[1]
+
contours, hierarchy = cv2.findContours(avg, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image = cv2.drawContours(frame, contours, -1, (0, 255, 0), 2)
cv2.imshow('win1', image)