I am using open cv to perform background subtraction. where i want to remove all moving objects from sequence of images. But at the end result image still contain some moving object. My code is below. Please suggest me how i can do it. thanks.
cv::Mat fgMaskMOG2;
cv::BackgroundSubtractorMOG2 pMOG2=cv::BackgroundSubtractorMOG2();
int i=1;
while (i<3) {
NSString *path=[[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"IMG_%d",i] ofType:@"JPG"];
cv::Mat frame =cv::imread([path UTF8String]);
pMOG2.operator()(frame, fgMaskMOG2);
i++;
}
cv::Mat output;
pMOG2.getBackgroundImage(output);
UIImage *imge=[self UIImageFromCVMat:fgMaskMOG2];
UIImage *imge2=[self UIImageFromCVMat:output];
Here are images which i am processing.
Here is result which i am getting.