SourceXtractorPlusPlus
0.19.2
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Segmentation
SegmentationFactory.cpp
Go to the documentation of this file.
1
23
#include <iostream>
24
25
#include "
Configuration/ConfigManager.h
"
26
27
#include "
SEFramework/Image/VectorImage.h
"
28
#include "
SEFramework/Source/SourceWithOnDemandPropertiesFactory.h
"
29
#include "
SEFramework/Image/ImageProcessingList.h
"
30
31
#include "
SEImplementation/Segmentation/BackgroundConvolution.h
"
32
#include "
SEImplementation/Segmentation/LutzSegmentation.h
"
33
#include "
SEImplementation/Segmentation/BFSSegmentation.h
"
34
#include "
SEImplementation/Segmentation/SegmentationFactory.h
"
35
36
#ifdef WITH_ML_SEGMENTATION
37
#include "
SEImplementation/Segmentation/MLSegmentation.h
"
38
#endif
39
40
41
using namespace
Euclid::Configuration
;
42
43
namespace
SourceXtractor
{
44
45
SegmentationFactory::SegmentationFactory
(
std::shared_ptr<TaskProvider>
task_provider)
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
50
void
SegmentationFactory::reportConfigDependencies
(
Euclid::Configuration::ConfigManager
&
manager
)
const
{
51
manager
.registerConfiguration<
SegmentationConfig
>();
52
}
53
54
void
SegmentationFactory::configure
(
Euclid::Configuration::ConfigManager
&
manager
) {
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
64
std::shared_ptr<Segmentation>
SegmentationFactory::createSegmentation
()
const
{
65
66
auto
segmentation
=
std::make_shared<Segmentation>
(
m_filter
);
67
switch
(
m_algorithm
) {
68
case
SegmentationConfig::Algorithm::LUTZ
:
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
;
73
case
SegmentationConfig::Algorithm::BFS
:
74
segmentation
->setLabelling<
BFSSegmentation
>(
75
std::make_shared<SourceWithOnDemandPropertiesFactory>
(
m_task_provider
),
m_bfs_max_delta
);
76
break
;
77
#ifdef WITH_ML_SEGMENTATION
78
case
SegmentationConfig::Algorithm::ML
:
79
segmentation
->setLabelling<
MLSegmentation
>(
80
std::make_shared<SourceWithOnDemandPropertiesFactory>
(
m_task_provider
),
m_model_path
,
m_ml_threshold
);
81
break
;
82
#endif
83
case
SegmentationConfig::Algorithm::UNKNOWN
:
84
default
:
85
throw
Elements::Exception
(
"Unknown segmentation algorithm."
);
86
}
87
88
return
segmentation
;
89
}
90
91
}
// SEImplementation namespace
BFSSegmentation.h
BackgroundConvolution.h
ConfigManager.h
ImageProcessingList.h
LutzSegmentation.h
MLSegmentation.h
SegmentationFactory.h
SourceWithOnDemandPropertiesFactory.h
VectorImage.h
Elements::Exception
Euclid::Configuration::ConfigManager
SourceXtractor::BFSSegmentation
Implements a Segmentation based on the BFS algorithm.
Definition
BFSSegmentation.h:31
SourceXtractor::LutzSegmentation
Definition
LutzSegmentation.h:38
SourceXtractor::MLSegmentation
Implements a Segmentation based on CNN.
Definition
MLSegmentation.h:32
SourceXtractor::SegmentationConfig
Used to select a Segmentation algorithm.
Definition
SegmentationConfig.h:38
SourceXtractor::SegmentationConfig::Algorithm::LUTZ
@ LUTZ
SourceXtractor::SegmentationConfig::Algorithm::UNKNOWN
@ UNKNOWN
SourceXtractor::SegmentationConfig::Algorithm::BFS
@ BFS
SourceXtractor::SegmentationConfig::Algorithm::ML
@ ML
SourceXtractor::SegmentationFactory::m_model_path
std::string m_model_path
Definition
SegmentationFactory.h:64
SourceXtractor::SegmentationFactory::reportConfigDependencies
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
Definition
SegmentationFactory.cpp:50
SourceXtractor::SegmentationFactory::m_filter
std::shared_ptr< DetectionImageFrame::ImageFilter > m_filter
Definition
SegmentationFactory.h:56
SourceXtractor::SegmentationFactory::m_lutz_window_size
int m_lutz_window_size
Definition
SegmentationFactory.h:61
SourceXtractor::SegmentationFactory::m_bfs_max_delta
int m_bfs_max_delta
Definition
SegmentationFactory.h:62
SourceXtractor::SegmentationFactory::configure
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
Definition
SegmentationFactory.cpp:54
SourceXtractor::SegmentationFactory::m_ml_threshold
double m_ml_threshold
Definition
SegmentationFactory.h:65
SourceXtractor::SegmentationFactory::m_task_provider
std::shared_ptr< TaskProvider > m_task_provider
Definition
SegmentationFactory.h:59
SourceXtractor::SegmentationFactory::createSegmentation
std::shared_ptr< Segmentation > createSegmentation() const
Definition
SegmentationFactory.cpp:64
SourceXtractor::SegmentationFactory::SegmentationFactory
SegmentationFactory(std::shared_ptr< TaskProvider > task_provider)
Constructor.
Definition
SegmentationFactory.cpp:45
SourceXtractor::SegmentationFactory::m_algorithm
SegmentationConfig::Algorithm m_algorithm
Definition
SegmentationFactory.h:58
std::function
Euclid::Configuration
SourceXtractor
Definition
Aperture.h:30
Generated by
1.9.8