26 #include <boost/regex.hpp>
28 using boost::regex_match;
31 #include <boost/algorithm/string.hpp>
44 namespace po = boost::program_options;
55 SegmentationConfig::SegmentationConfig(
long manager_id) :
Configuration(manager_id),
60 return { {
"Detection image", {
62 "Segmentation algorithm to be used. Currently LUTZ is the only choice"},
64 "Disables filtering"},
68 "Lutz sliding window size (0=disable)"},
74 if (algorithm_name !=
"LUTZ") {
81 if (filter_filename !=
"") {
101 convolution_kernel->setValue(0,0, 1);
102 convolution_kernel->setValue(0,1, 2);
103 convolution_kernel->setValue(0,2, 1);
105 convolution_kernel->setValue(1,0, 2);
106 convolution_kernel->setValue(1,1, 4);
107 convolution_kernel->setValue(1,2, 2);
109 convolution_kernel->setValue(2,0, 1);
110 convolution_kernel->setValue(2,1, 2);
111 convolution_kernel->setValue(2,2, 1);
113 return std::make_shared<BackgroundConvolution>(convolution_kernel,
true);
136 segConfigLogger.
info() <<
"Loaded segmentation filter: " <<
filename <<
" height: " << convolution_kernel->getHeight() <<
" width: " << convolution_kernel->getWidth();
139 return std::make_shared<BackgroundConvolution>(convolution_kernel,
true);
151 enum class LoadState {
157 LoadState state = LoadState::STATE_START;
158 bool normalize =
false;
160 unsigned int kernel_width = 0;
162 while (file.
good()) {
167 if (line.
size() == 0) {
175 case LoadState::STATE_START:
178 line_stream >> conv >> norm_type;
179 if (conv !=
"CONV") {
182 if (norm_type ==
"NORM") {
184 }
else if (norm_type ==
"NONORM") {
189 state = LoadState::STATE_FIRST_LINE;
192 case LoadState::STATE_FIRST_LINE:
193 while (line_stream.
good()) {
194 line_stream >> value;
197 kernel_width = kernel_data.
size();
198 state = LoadState::STATE_OTHER_LINES;
200 case LoadState::STATE_OTHER_LINES:
201 while (line_stream.
good()) {
202 line_stream >> value;
210 auto kernel_height = kernel_data.
size() / kernel_width;
214 segConfigLogger.
info() <<
"Loaded segmentation filter: " <<
filename <<
" width: " << convolution_kernel->getWidth() <<
" height: " << convolution_kernel->getHeight();
217 return std::make_shared<BackgroundConvolution>(convolution_kernel, normalize);