26 #include <boost/regex.hpp>
28 using boost::regex_match;
31 #include <boost/algorithm/string.hpp>
44 namespace po = boost::program_options;
56 SegmentationConfig::SegmentationConfig(
long manager_id) :
Configuration(manager_id),
57 m_selected_algorithm(
Algorithm::
UNKNOWN), m_lutz_window_size(0), m_bfs_max_delta(1000) {
61 return { {
"Detection image", {
63 "Segmentation algorithm to be used (LUTZ or TILES)"},
65 "Disables filtering"},
69 "Lutz sliding window size (0=disable)"},
71 "BFS algorithm max source x/y size (default=1000)"},
77 if (algorithm_name ==
"LUTZ") {
79 }
else if (algorithm_name ==
"BFS") {
90 if (filter_filename !=
"") {
109 convolution_kernel->setValue(0,0, 1);
110 convolution_kernel->setValue(0,1, 2);
111 convolution_kernel->setValue(0,2, 1);
113 convolution_kernel->setValue(1,0, 2);
114 convolution_kernel->setValue(1,1, 4);
115 convolution_kernel->setValue(1,2, 2);
117 convolution_kernel->setValue(2,0, 1);
118 convolution_kernel->setValue(2,1, 2);
119 convolution_kernel->setValue(2,2, 1);
121 return std::make_shared<BackgroundConvolution>(convolution_kernel,
true);
144 segConfigLogger.
info() <<
"Loaded segmentation filter: " <<
filename <<
" height: " << convolution_kernel->getHeight() <<
" width: " << convolution_kernel->getWidth();
147 return std::make_shared<BackgroundConvolution>(convolution_kernel,
true);
152 line_stream >> conv >> norm_type;
153 if (conv !=
"CONV") {
156 if (norm_type ==
"NORM") {
159 else if (norm_type ==
"NONORM") {
166 template <
typename T>
169 while (line_stream.
good()) {
170 line_stream >> value;
184 enum class LoadState {
190 LoadState state = LoadState::STATE_START;
191 bool normalize =
false;
193 unsigned int kernel_width = 0;
195 while (file.
good()) {
200 if (line.
size() == 0) {
207 case LoadState::STATE_START:
209 state = LoadState::STATE_FIRST_LINE;
211 case LoadState::STATE_FIRST_LINE:
213 kernel_width = kernel_data.
size();
214 state = LoadState::STATE_OTHER_LINES;
216 case LoadState::STATE_OTHER_LINES:
223 auto kernel_height = kernel_data.
size() / kernel_width;
227 segConfigLogger.
info() <<
"Loaded segmentation filter: " <<
filename <<
" width: " << convolution_kernel->getWidth() <<
" height: " << convolution_kernel->getHeight();
230 return std::make_shared<BackgroundConvolution>(convolution_kernel, normalize);
static Logging getLogger(const std::string &name="")
void info(const std::string &logMessage)
T regex_replace(T... args)