SourceXtractorPlusPlus 0.19.2
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SegmentationFactory.cpp
Go to the documentation of this file.
1
23#include <iostream>
24
26
30
35
36#ifdef WITH_ML_SEGMENTATION
38#endif
39
40
41using namespace Euclid::Configuration;
42
43namespace SourceXtractor {
44
46 : m_algorithm(SegmentationConfig::Algorithm::UNKNOWN),
47 m_task_provider(task_provider), m_lutz_window_size(0), m_bfs_max_delta(0), m_ml_threshold(0.) {
48}
49
52}
53
55 auto segmentation_config = manager.getConfiguration<SegmentationConfig>();
56 m_algorithm = segmentation_config.getAlgorithmOption();
57 m_filter = segmentation_config.getFilter();
58 m_lutz_window_size = segmentation_config.getLutzWindowSize();
59 m_bfs_max_delta = segmentation_config.getBfsMaxDelta();
60 m_model_path = segmentation_config.getOnnxModelPath();
61 m_ml_threshold = segmentation_config.getMLThreashold();
62}
63
65
66 auto segmentation = std::make_shared<Segmentation>(m_filter);
67 switch (m_algorithm) {
69 //FIXME Use a factory from parameter
70 segmentation->setLabelling<LutzSegmentation>(
71 std::make_shared<SourceWithOnDemandPropertiesFactory>(m_task_provider), m_lutz_window_size);
72 break;
74 segmentation->setLabelling<BFSSegmentation>(
75 std::make_shared<SourceWithOnDemandPropertiesFactory>(m_task_provider), m_bfs_max_delta);
76 break;
77#ifdef WITH_ML_SEGMENTATION
79 segmentation->setLabelling<MLSegmentation>(
80 std::make_shared<SourceWithOnDemandPropertiesFactory>(m_task_provider), m_model_path, m_ml_threshold);
81 break;
82#endif
84 default:
85 throw Elements::Exception("Unknown segmentation algorithm.");
86 }
87
88 return segmentation;
89}
90
91} // SEImplementation namespace
Implements a Segmentation based on the BFS algorithm.
Implements a Segmentation based on CNN.
Used to select a Segmentation algorithm.
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
std::shared_ptr< DetectionImageFrame::ImageFilter > m_filter
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
std::shared_ptr< TaskProvider > m_task_provider
std::shared_ptr< Segmentation > createSegmentation() const
SegmentationFactory(std::shared_ptr< TaskProvider > task_provider)
Constructor.
SegmentationConfig::Algorithm m_algorithm