Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

opencv 2.4.11 BackgroundSubtractorMOG2 problems with background and foreground

$
0
0
I'm having problems getting BackgroundSubtractorMOG2 to work. I'm using: 1) OpenCV 2.4.11 (x64) 2) Visual Studio 2010 Here are 2 problems I'm experiencing: 1) The foreground (e.g. fgMask) and background (e.g. bgImg) don't seem correct. The background image is identical to the current image (e.g. frame), and the foreground image looks like it might only have been computed from a single frame. 2) When I include the line mog2.set("detectShadows",false); the fgMask output is all white (i.e. 255). Sample Code: double learningRate = 0.01; //I've tried a few other values too cv::BackgroundSubtractorMOG2 mog2; //mog2.set("detectShadows",false); //including this line causes fgMask to be all white mog2.set("nShadowDetection", 20); for each image fileName //replaced C++ for conditions line w/ psuedocode for simplicity { cv::Mat frame; frame = cv::imread(fileName, CV_LOAD_IMAGE_GRAYSCALE); if( frame.empty()) { std::cout << "frame is empty" << std::endl; break; } cv::Mat fgMask; mog2(frame, fgMask, learningRate); //display images cv::imshow("original", frame); cv::imshow("fgMask", fgMask); cv::imshow("bgImg", bgImg); keyboard = cv::waitKey(10000); cv::destroyAllWindows(); }

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>