BackgroundsubtractorMOG2 result is not satisfactory.
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++;![image description](http://)
}
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.
i hope, you're not trying literally with those 4 images. the BackGroundSubtractor classes are meant to be used with a continuous stream, and it has to build a model over time.
Well i also tired with other set of images which are taken in a sequence and from one place with out moving. but results are same.
beside that i am using 2.4 version instead of 3.0 because when i use 3.0 i get bad memory exception in apply method. Do you any idea about this ?
"bad memory exception in apply method Do you any idea about this" - no.
and again, it will never work with just a few images. wrong tool for the job, then.
(also, just saying, the fgMaskMOG2 image is the result of that operation, not the getBackgroundImage() (which is generated from the internal model))
I see. thanks for the help. Any other suggested tool for such kind of task ?
what is your task, exactly ?
you probably need an image with plain background, and absdiff() later images
i want to get a background image from a sequence of images by removing all moving objects.