opencv segmentation

asked 2015-01-11 03:11:22 -0500

Vivek gravatar image

updated 2015-01-11 10:16:21 -0500

I am working on a project in which i need segmentated video but after apply the segmentation to the video as given in the opencv docs , the human person i m getting is not complete white. My means of say that is there is a boundary of white pixel around the person and inside part is black and the same color as background(black). Can any one help me to obtain the completely white pixeled human person ! Thanks...

My code is :

import numpy as np 
import cv2

cap=cv2.VideoCapture('sample4.avi') 


fourcc = cv2.cv.CV_FOURCC(*'XVID')
fgbg = cv2.BackgroundSubtractorMOG()
out=cv2.VideoWriter('Segmented_Recorded_video.avi',fourcc,20.0,(640,480))


while cap.isOpened():
    ret, frame=cap.read() #capture frame by frame
    fgmask=fgbg.apply(frame)
    out.write(fgmask)

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

cap.release()
out.release()
cv2.destroyAllWindows()
edit retag flag offensive close merge delete

Comments

1

hi, vivek, can you try to format the code for better readability ?

(edit the question, mark the code with mouse, press 10101 button)

berak gravatar imageberak ( 2015-01-11 03:45:24 -0500 )edit
2

Some example images would really help to understand your problem.

FooBar gravatar imageFooBar ( 2015-01-11 06:38:15 -0500 )edit

Here is the snapshot of the video before and after segmentation. After Segmentation : http://postimg.org/image/c846si9q5/ Before Segmentation: http://postimg.org/image/jwr0fjahh/ Whole background is black that is fine but human body should be completely white ..

Vivek gravatar imageVivek ( 2015-01-17 07:29:14 -0500 )edit