From a107071c777c64c27973e02e0f7445e671d10451 Mon Sep 17 00:00:00 2001 From: Kees-V Date: Wed, 13 May 2015 16:08:03 +0200 Subject: [PATCH] Motion detector compatible with OpenCV 2.4.x --- src/video/motiondetector.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/motiondetector.cpp b/src/video/motiondetector.cpp index c115c2b..db53dcf 100644 --- a/src/video/motiondetector.cpp +++ b/src/video/motiondetector.cpp @@ -4,7 +4,7 @@ using namespace cv; MotionDetector::MotionDetector() { - pMOG2 = cv::createBackgroundSubtractorMOG2(); + pMOG2 = new BackgroundSubtractorMOG2(); } MotionDetector::~MotionDetector() @@ -14,7 +14,7 @@ MotionDetector::~MotionDetector() void MotionDetector::ResetMotionDetection(cv::Mat* frame) { - pMOG2->apply(*frame, fgMaskMOG2, 1); + pMOG2->operator()(*frame, fgMaskMOG2, 1); } cv::Rect MotionDetector::MotionDetect(cv::Mat* frame) @@ -27,7 +27,7 @@ cv::Rect MotionDetector::MotionDetect(cv::Mat* frame) cv::Rect largest_rect, rect_temp; // Detect motion - pMOG2->apply(*frame, fgMaskMOG2, -1); + pMOG2->operator()(*frame, fgMaskMOG2, -1); //Remove noise cv::erode(fgMaskMOG2, fgMaskMOG2, getStructuringElement(cv::MORPH_RECT, cv::Size(6, 6))); // Find the contours of motion areas in the image