Motion detection false alarms from light changes
In order to use the motion detection in my software with OpenCV, I use this elementary approach:
cv::GaussianBlur(Frame, Frame, cv::Size(5, 5), 0, 0, cv::BORDER_DEFAULT);
MOG2Background.operator ()(Frame, Foreground);
MOG2Background.getBackgroundImage(Background);
std::vector<std::vector<cv::Point> > Contours;
cv::findContours(Foreground, Contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
cv::rectangle(Foreground, cv::Point(0, 0), cv::Point(Foreground.cols, Foreground.rows), cv::Scalar(0, 0, 0), CV_FILLED);
cv::drawContours(Foreground, Contours, -1, cv::Scalar(255, 255, 255), CV_FILLED);
This code works correctly but, if there is a flash light from the Window (by a car lights during the night for example) I obtain an alarm. How can I do to optimize my code?
Denis, if my answer addressed your question, pls mark it as answered.