background_subtractor.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2017
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the institute nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * Notes:
37  * The following code makes use of the OpenCV library.
38  * OpenCV is licensed under the terms of the 3-clause BSD License.
39  *
40  * Authors: Franz Albers, Christoph Rösmann
41  *********************************************************************/
42 
43 #ifndef BACKGROUNDSUBTRACTOR_H_
44 #define BACKGROUNDSUBTRACTOR_H_
45 
46 #include <cv_bridge/cv_bridge.h>
47 
58 {
59 public:
60  struct Params
61  {
62  double alpha_slow;
63  double alpha_fast;
64  double beta;
69  };
70 
72  BackgroundSubtractor(const Params& parameters);
73 
81  void apply(const cv::Mat& image, cv::Mat& fg_mask, int shift_x = 0, int shift_y = 0);
82 
88  void visualize(const std::string& name, const cv::Mat& image);
89 
96  void writeMatToYAML(const std::string& filename, const std::vector<cv::Mat>& mat_vec);
97 
99  void updateParameters(const Params& parameters);
100 
101 private:
103  void transformToCurrentFrame(int shift_x, int shift_y);
104 
107  cv::Mat current_frame_;
108 
111 
113 };
114 
115 #endif // BACKGROUNDSUBTRACTOR_H_
BackgroundSubtractor::BackgroundSubtractor
BackgroundSubtractor(const Params &parameters)
Constructor that accepts a specific parameter configuration.
Definition: background_subtractor.cpp:5
BackgroundSubtractor::Params::min_sep_between_fast_and_slow_filter
double min_sep_between_fast_and_slow_filter
Definition: background_subtractor.h:65
BackgroundSubtractor::Params
Definition: background_subtractor.h:60
BackgroundSubtractor
Perform background subtraction to extract the "moving" foreground.
Definition: background_subtractor.h:57
BackgroundSubtractor::occupancy_grid_slow_
cv::Mat occupancy_grid_slow_
Definition: background_subtractor.h:106
BackgroundSubtractor::previous_shift_y_
int previous_shift_y_
Definition: background_subtractor.h:110
BackgroundSubtractor::Params::alpha_slow
double alpha_slow
Filter constant (learning rate) of the slow filter part.
Definition: background_subtractor.h:62
BackgroundSubtractor::current_frame_
cv::Mat current_frame_
Definition: background_subtractor.h:107
BackgroundSubtractor::previous_shift_x_
int previous_shift_x_
Definition: background_subtractor.h:109
BackgroundSubtractor::updateParameters
void updateParameters(const Params &parameters)
Update internal parameters.
Definition: background_subtractor.cpp:112
BackgroundSubtractor::params_
Params params_
Definition: background_subtractor.h:112
BackgroundSubtractor::Params::morph_size
int morph_size
Definition: background_subtractor.h:68
BackgroundSubtractor::Params::alpha_fast
double alpha_fast
Filter constant (learning rate) of the fast filter part.
Definition: background_subtractor.h:63
BackgroundSubtractor::Params::beta
double beta
Definition: background_subtractor.h:64
cv_bridge.h
BackgroundSubtractor::Params::max_occupancy_neighbors
double max_occupancy_neighbors
Definition: background_subtractor.h:67
BackgroundSubtractor::occupancy_grid_fast_
cv::Mat occupancy_grid_fast_
Definition: background_subtractor.h:105
BackgroundSubtractor::Params::min_occupancy_probability
double min_occupancy_probability
Definition: background_subtractor.h:66
BackgroundSubtractor::apply
void apply(const cv::Mat &image, cv::Mat &fg_mask, int shift_x=0, int shift_y=0)
Computes a foreground mask.
Definition: background_subtractor.cpp:9
BackgroundSubtractor::visualize
void visualize(const std::string &name, const cv::Mat &image)
OpenCV Visualization.
Definition: background_subtractor.cpp:101
BackgroundSubtractor::writeMatToYAML
void writeMatToYAML(const std::string &filename, const std::vector< cv::Mat > &mat_vec)
Export vector of matrices to yaml file.
BackgroundSubtractor::transformToCurrentFrame
void transformToCurrentFrame(int shift_x, int shift_y)
Transform/shift all internal matrices/grids according to a given translation vector.
Definition: background_subtractor.cpp:84


costmap_converter
Author(s): Christoph Rösmann , Franz Albers , Otniel Rinaldo
autogenerated on Fri Sep 20 2024 02:19:25