Files
libuvosunwrap/bgremoval.cpp
uvos 38680f029c add logging engine
add options to control harris algorithum
2020-10-27 20:59:19 +01:00

23 lines
664 B
C++

#include "bgremoval.h"
#include <iostream>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/bgsegm.hpp>
#include "log.h"
bool createMask(const cv::Mat& in, cv::Mat& mask, const cv::Mat& bg)
{
if(in.size != bg.size || in.type() != bg.type())
{
Log(Log::ERROR)<<"input image and backgournd image size and type needs to be the same";
return false;
}
cv::Ptr<cv::BackgroundSubtractorMOG2> bgremv = cv::createBackgroundSubtractorMOG2(2,10,false);
bgremv->apply(bg, mask, 1);
bgremv->apply(in, mask, 0);
cv::GaussianBlur(mask,mask,cv::Size(49,49), 15);
cv::threshold(mask, mask, 70, 255, cv::THRESH_BINARY);
return true;
}