4 * Created on: May 7, 2012
5 * Author: Andrew B. Godbehere
8 #include "opencv2/video.hpp"
9 #include "opencv2/videoio.hpp"
10 #include "opencv2/highgui.hpp"
11 #include <opencv2/core/utility.hpp>
19 "\nA program demonstrating the use and capabilities of a particular BackgroundSubtraction\n"
20 "algorithm described in A. Godbehere, A. Matsukawa, K. Goldberg, \n"
21 "\"Visual Tracking of Human Visitors under Variable-Lighting Conditions for a Responsive\n"
22 "Audio Art Installation\", American Control Conference, 2012, used in an interactive\n"
23 "installation at the Contemporary Jewish Museum in San Francisco, CA from March 31 through\n"
26 "./BackgroundSubtractorGMG_sample\n"
27 "Using OpenCV version " << CV_VERSION << "\n"<<std::endl;
30 int main(int argc, char** argv)
35 setUseOptimized(true);
38 Ptr<BackgroundSubtractor> fgbg = createBackgroundSubtractorGMG(20, 0.7);
41 std::cerr << "Failed to create BackgroundSubtractor.GMG Algorithm." << std::endl;
53 std::cerr << "Cannot read video. Try moving video file to sample directory." << std::endl;
57 Mat frame, fgmask, segm;
59 namedWindow("FG Segmentation", WINDOW_NORMAL);
68 fgbg->apply(frame, fgmask);
70 frame.convertTo(segm, CV_8U, 0.5);
71 add(frame, Scalar(100, 100, 0), segm, fgmask);
73 imshow("FG Segmentation", segm);
76 if (c == 'q' || c == 'Q' || (c & 255) == 27)