Retrieving Foreground from static background
0 down vote favorite
I am working on a video processing project which involves tracking objects which can be stationary or moving. The actual static background is available at the beginning. I have writeen a simple code for getting the foreground :
cv::Mat temp;
cv::absdiff(background,camFrame,temp);
threshold(temp, temp, 128, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);
cv::erode(temp,temp,cv::Mat());
But unfortunately the code doesnt seem to work well in retrieving the foreground objects...I will be glab if someboday provide me with some suggestions and bits of code...