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') #argument 0 represent the camera number 0 of the computer
fourcc=cv2.VideoWriter_fourcc('X','V','I','D')
fourcc = cv2.cv.CV_FOURCC(*'XVID')
fgbg=cv2.createBackgroundSubtractorMOG()
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) #gray= cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) cv2.imshow('Segmentation Video',fgmask) k=cv2.waitKey(30) & 0xff if k==27: break
cap.release() out.release() cv2.destroyAllWindows()