mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 04:40:51 +08:00
Motion detector compatible with OpenCV 2.4.x
This commit is contained in:
@@ -4,7 +4,7 @@ using namespace cv;
|
|||||||
|
|
||||||
MotionDetector::MotionDetector()
|
MotionDetector::MotionDetector()
|
||||||
{
|
{
|
||||||
pMOG2 = cv::createBackgroundSubtractorMOG2();
|
pMOG2 = new BackgroundSubtractorMOG2();
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionDetector::~MotionDetector()
|
MotionDetector::~MotionDetector()
|
||||||
@@ -14,7 +14,7 @@ MotionDetector::~MotionDetector()
|
|||||||
|
|
||||||
void MotionDetector::ResetMotionDetection(cv::Mat* frame)
|
void MotionDetector::ResetMotionDetection(cv::Mat* frame)
|
||||||
{
|
{
|
||||||
pMOG2->apply(*frame, fgMaskMOG2, 1);
|
pMOG2->operator()(*frame, fgMaskMOG2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Rect MotionDetector::MotionDetect(cv::Mat* frame)
|
cv::Rect MotionDetector::MotionDetect(cv::Mat* frame)
|
||||||
@@ -27,7 +27,7 @@ cv::Rect MotionDetector::MotionDetect(cv::Mat* frame)
|
|||||||
cv::Rect largest_rect, rect_temp;
|
cv::Rect largest_rect, rect_temp;
|
||||||
|
|
||||||
// Detect motion
|
// Detect motion
|
||||||
pMOG2->apply(*frame, fgMaskMOG2, -1);
|
pMOG2->operator()(*frame, fgMaskMOG2, -1);
|
||||||
//Remove noise
|
//Remove noise
|
||||||
cv::erode(fgMaskMOG2, fgMaskMOG2, getStructuringElement(cv::MORPH_RECT, cv::Size(6, 6)));
|
cv::erode(fgMaskMOG2, fgMaskMOG2, getStructuringElement(cv::MORPH_RECT, cv::Size(6, 6)));
|
||||||
// Find the contours of motion areas in the image
|
// Find the contours of motion areas in the image
|
||||||
|
Reference in New Issue
Block a user