1

I want to use this code

fgbg = cv2.createBackgroundSubtractorMOG2(detectShadows=True)
cap = cv2.VideoCapture('drunker-1.mp4')

while True:
    grabed, img = cap.read()
    if not grabed:
        break
    ori = img.copy()
    gray = cv2.cvtColor(ori, cv2.COLOR_BGR2GRAY) 
    img = fgbg.apply(gray)
    ret, img = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)

extract human body from this video:

https://www.youtube.com/watch?v=Xvj4Ud-RKrM

but I got result like this: enter image description here

This is complete messy,and I think it caused by light and shadow changing,so how to reduce these noises?Thanks in advance!!

Alex Luya
  • 9,412
  • 15
  • 59
  • 91

1 Answers1

0

You can try to blur the image using GaussianBlur before background subtraction:

Imgproc.GaussianBlur(resize_blur_Img, resize_blur_Img, new Size(9, 9), 2, 2);
ProgIsMetal
  • 462
  • 2
  • 5
  • 18