SourceXtractorPlusPlus
0.21
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/AssocSegmentation.h
"
35
36
#ifdef WITH_ML_SEGMENTATION
37
#include "
SEImplementation/Segmentation/MLSegmentation.h
"
38
#endif
39
40
#include "
SEImplementation/Segmentation/SegmentationFactory.h
"
41
42
using namespace
Euclid::Configuration
;
43
44
namespace
SourceXtractor
{
45
46
SegmentationFactory::SegmentationFactory
(
std::shared_ptr<TaskProvider>
task_provider)
47
: m_algorithm(
SegmentationConfig
::Algorithm::UNKNOWN),
48
m_task_provider(task_provider), m_lutz_window_size(0), m_bfs_max_delta(0), m_ml_threshold(0.) {
49
}
50
51
void
SegmentationFactory::reportConfigDependencies
(
Euclid::Configuration::ConfigManager
&
manager
)
const
{
52
manager
.registerConfiguration<
AssocModeConfig
>();
53
manager
.registerConfiguration<
SegmentationConfig
>();
54
}
55
56
void
SegmentationFactory::configure
(
Euclid::Configuration::ConfigManager
&
manager
) {
57
auto
segmentation_config
=
manager
.getConfiguration<
SegmentationConfig
>();
58
m_algorithm
=
segmentation_config
.getAlgorithmOption();
59
m_filter
=
segmentation_config
.getFilter();
60
m_lutz_window_size
=
segmentation_config
.getLutzWindowSize();
61
m_bfs_max_delta
=
segmentation_config
.getBfsMaxDelta();
62
m_model_path
=
segmentation_config
.getOnnxModelPath();
63
m_ml_threshold
=
segmentation_config
.getMLThreashold();
64
65
auto
assoc_config
=
manager
.getConfiguration<
AssocModeConfig
>();
66
m_catalogs
=
assoc_config
.getCatalogs();
67
}
68
69
std::shared_ptr<Segmentation>
SegmentationFactory::createSegmentation
()
const
{
70
auto
segmentation
=
std::make_shared<Segmentation>
(
m_filter
);
71
switch
(
m_algorithm
) {
72
case
SegmentationConfig::Algorithm::LUTZ
:
73
//FIXME Use a factory from parameter
74
segmentation
->setLabelling<
LutzSegmentation
>(
75
std::make_shared<SourceWithOnDemandPropertiesFactory>
(
m_task_provider
),
m_lutz_window_size
);
76
break
;
77
case
SegmentationConfig::Algorithm::BFS
:
78
segmentation
->setLabelling<
BFSSegmentation
>(
79
std::make_shared<SourceWithOnDemandPropertiesFactory>
(
m_task_provider
),
m_bfs_max_delta
);
80
break
;
81
#ifdef WITH_ML_SEGMENTATION
82
case
SegmentationConfig::Algorithm::ML
:
83
segmentation
->setLabelling<
MLSegmentation
>(
84
std::make_shared<SourceWithOnDemandPropertiesFactory>
(
m_task_provider
),
m_model_path
,
m_ml_threshold
);
85
break
;
86
#endif
87
case
SegmentationConfig::Algorithm::ASSOC
:
88
{
89
segmentation
->setLabelling<
AssocSegmentation
>(
90
std::make_shared<SourceWithOnDemandPropertiesFactory>
(
m_task_provider
),
m_catalogs
.at(0));
91
break
;
92
}
93
case
SegmentationConfig::Algorithm::UNKNOWN
:
94
default
:
95
throw
Elements::Exception
(
"Unknown segmentation algorithm."
);
96
}
97
98
return
segmentation
;
99
}
100
101
}
// SEImplementation namespace
AssocSegmentation.h
BFSSegmentation.h
BackgroundConvolution.h
ImageProcessingList.h
LutzSegmentation.h
MLSegmentation.h
SegmentationFactory.h
SourceWithOnDemandPropertiesFactory.h
VectorImage.h
Elements::Exception
Euclid::Configuration::ConfigManager
SourceXtractor::AssocModeConfig
Definition
AssocModeConfig.h:31
SourceXtractor::AssocSegmentation
Implements a Segmentation based on CNN.
Definition
AssocSegmentation.h:25
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::ASSOC
@ ASSOC
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:67
SourceXtractor::SegmentationFactory::reportConfigDependencies
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
Definition
SegmentationFactory.cpp:51
SourceXtractor::SegmentationFactory::m_filter
std::shared_ptr< DetectionImageFrame::ImageFilter > m_filter
Definition
SegmentationFactory.h:59
SourceXtractor::SegmentationFactory::m_lutz_window_size
int m_lutz_window_size
Definition
SegmentationFactory.h:64
SourceXtractor::SegmentationFactory::m_bfs_max_delta
int m_bfs_max_delta
Definition
SegmentationFactory.h:65
SourceXtractor::SegmentationFactory::configure
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
Definition
SegmentationFactory.cpp:56
SourceXtractor::SegmentationFactory::m_catalogs
std::vector< std::vector< AssocModeConfig::CatalogEntry > > m_catalogs
Definition
SegmentationFactory.h:70
SourceXtractor::SegmentationFactory::m_ml_threshold
double m_ml_threshold
Definition
SegmentationFactory.h:68
SourceXtractor::SegmentationFactory::m_task_provider
std::shared_ptr< TaskProvider > m_task_provider
Definition
SegmentationFactory.h:62
SourceXtractor::SegmentationFactory::createSegmentation
std::shared_ptr< Segmentation > createSegmentation() const
Definition
SegmentationFactory.cpp:69
SourceXtractor::SegmentationFactory::SegmentationFactory
SegmentationFactory(std::shared_ptr< TaskProvider > task_provider)
Constructor.
Definition
SegmentationFactory.cpp:46
SourceXtractor::SegmentationFactory::m_algorithm
SegmentationConfig::Algorithm m_algorithm
Definition
SegmentationFactory.h:61
std::function
Euclid::Configuration
SourceXtractor
Definition
Aperture.h:30
Generated by
1.10.0