Background Subtraction

asked 2017-06-03 15:54:35 -0500

Volpe gravatar image

updated 2017-06-03 19:26:06 -0500

From a video, I want to subtract my hand from the static background,I used the function cv2.BackgroundSubtract(), but my problem is that my hand is mostly considered as part of the background, since it doesn't move much ( only the fingers moves) image description there's the source Code (i'm working with Python):

    import numpy as np
    import cv2

cap = cv2.VideoCapture(0)

bgModel = cv2.createBackgroundSubtractorMOG2()


while True:
    ret, frame = cap.read()
    fgmask = bgModel.apply(frame)

    #res = cv2.bitwise_and(frame, frame, mask=fgmask)

    cv2.imshow('frame',fgmask)
    k = cv2.waitKey(30) & 0xff
    if k == 27:
        break

cap.release()
cv2.destroyAllWindows()

Is there any other function that can do the job right ? I wanted to do a color skin recognition but I don't know how to do a Sampling Color directly from the video. Thanks for your Help

edit retag flag offensive close merge delete