split into many files

add better outlier rejection
add normalization
add background removal
This commit is contained in:
uvos 2020-10-22 11:21:12 +02:00
parent a5440ed857
commit 6defcad11b
12 changed files with 904 additions and 446 deletions

21
bgremoval.cpp Normal file
View file

@ -0,0 +1,21 @@
#include "bgremoval.h"
#include <iostream>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/bgsegm.hpp>
bool createMask(const cv::Mat& in, cv::Mat& mask, const cv::Mat& bg)
{
if(in.size != bg.size || in.type() != bg.type())
{
std::cerr<<"input image and backgournd image size and type needs to be the same\n";
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;
}