Skip to content
Snippets Groups Projects
Commit 7fd5b486 authored by Sebastian Gomez-Gonzalez's avatar Sebastian Gomez-Gonzalez
Browse files

Adding optional smoothing capabilities to the tracker

parent 39699bed
No related branches found
No related tags found
No related merge requests found
{
"ball_log_lh": {
"type": "cb_log_reg",
"conf": {
"conf": {
"weights": [
-4.3645153397769523,
-1.7528550846385467,
......@@ -31,7 +31,11 @@
-5.4301792573145677,
-4.7388290757015756,
-5.739125161010926
]
],
"gauss_smooth": {
"size": 5,
"sigma": 0
}
}
},
"binarizer": {
......
......@@ -16,6 +16,23 @@ namespace ball_tracking {
*/
namespace {
class GaussSmooth {
private:
int size;
double sigma;
public:
GaussSmooth(const json& conf) {
size = conf.at("size");
sigma = conf.at("sigma");
}
cv::Mat operator()(cv::InputArray _src) {
Mat dst;
GaussianBlur(_src, dst, Size(size,size), sigma, sigma);
return dst;
}
};
/**
* Color and background based logistic regression
*/
......@@ -23,18 +40,32 @@ namespace ball_tracking {
private:
Mat bkg; //!< Background image
Mat weights; //!< Model weights
vector<preproc> pre; //!< Preprocessing functions for the images
public:
cv::Mat operator()(cv::InputArray src) {
Mat pre_chain(cv::InputArray src) {
Mat tmp = src.getMat();
for (auto p : pre) {
tmp = p(tmp);
}
return tmp;
}
cv::Mat operator()(cv::InputArray _src) {
Mat src = pre_chain(_src);
if (bkg.empty()) {
bkg = src.getMat();
bkg = src;
}
return quadf_log_reg(src, bkg, weights);
}
CB_log_reg(const json& conf) {
weights = json2cvmat(conf.at("weights"));
if (conf.count("gauss_smooth")) {
pre.push_back(GaussSmooth(conf.at("gauss_smooth")));
}
if (conf.count("background")) {
bkg = imread(conf.at("background"), CV_LOAD_IMAGE_COLOR);
bkg = pre_chain( imread(conf.at("background"), CV_LOAD_IMAGE_COLOR) );
if (!bkg.data) {
throw std::logic_error("File not found for background image");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment