I am using OpenCV for motion detection and using back ground subtraction algo for this. I got the following code from net.
cv::Mat frame;
cv::Mat back;
cv::Mat fore;
cv::VideoCapture cap(0);
bg.nmixtures = 3;
bg.bShadowDetection = false;
const int history = 5;
cv::BackgroundSubtractorMOG2 bg (history,nmixtures,bShadowDetection);
std::vector<std::vector<cv::Point> > contours;
cv::namedWindow("Frame");
cv::namedWindow("Background");
for(;;)
{
cap >> frame;
bg.operator ()(frame,fore);
bg.getBackgroundImage(back);
cv::erode(fore,fore,cv::Mat());
cv::dilate(fore,fore,cv::Mat());
cv::findContours(fore,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
cv::drawContours(frame,contours,-1,cv::Scalar(0,0,255),2);
cv::imshow("Frame",frame);
cv::imshow("Background",back);
if(cv::waitKey(30) >= 0) break;
}
So can i set a threshold so that if the change in new and old frame is more than the threshold then dont do anything. Or may be some other algorithm that should suit my situation of capturing only slow moving object.