refactored video module; use the new-style algorithms now

This commit is contained in:
Vadim Pisarevsky
2013-03-20 19:51:49 +04:00
parent 14a0abbfa9
commit 07e0f7bf59
28 changed files with 1113 additions and 2270 deletions

View File

@@ -32,16 +32,13 @@ int main(int argc, char** argv)
setUseOptimized(true);
setNumThreads(8);
Ptr<BackgroundSubtractorGMG> fgbg = Algorithm::create<BackgroundSubtractorGMG>("BackgroundSubtractor.GMG");
Ptr<BackgroundSubtractor> fgbg = createBackgroundSubtractorGMG(20, 0.7);
if (fgbg.empty())
{
std::cerr << "Failed to create BackgroundSubtractor.GMG Algorithm." << std::endl;
return -1;
}
fgbg->set("initializationFrames", 20);
fgbg->set("decisionThreshold", 0.7);
VideoCapture cap;
if (argc > 1)
cap.open(argv[1]);
@@ -65,9 +62,9 @@ int main(int argc, char** argv)
if (frame.empty())
break;
(*fgbg)(frame, fgmask);
fgbg->apply(frame, fgmask);
frame.copyTo(segm);
frame.convertTo(segm, CV_8U, 0.5);
add(frame, Scalar(100, 100, 0), segm, fgmask);
imshow("FG Segmentation", segm);