opencv segmentation
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()
hi, vivek, can you try to format the code for better readability ?
(edit the question, mark the code with mouse, press 10101 button)
Some example images would really help to understand your problem.
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 ..