SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
SEFramework
Pipeline
Segmentation.h
Go to the documentation of this file.
1
23
#ifndef _SEFRAMEWORK_PIPELINE_SEGMENTATION_H
24
#define _SEFRAMEWORK_PIPELINE_SEGMENTATION_H
25
26
#include <memory>
27
#include <type_traits>
28
29
#include "
SEFramework/CoordinateSystem/CoordinateSystem.h
"
30
#include "
SEFramework/Frame/Frame.h
"
31
#include "
SEFramework/Image/Image.h
"
32
#include "
SEFramework/Pipeline/PipelineStage.h
"
33
#include "
SEFramework/Pipeline/SourceGrouping.h
"
34
#include "
SEFramework/Property/DetectionFrame.h
"
35
#include "
SEFramework/Source/SourceInterface.h
"
36
37
namespace
SourceXtractor
{
38
43
struct
SegmentationProgress
{
44
int
position
,
total
;
45
};
46
53
class
Segmentation
:
public
PipelineEmitter
<SourceInterface> ,
public
Observable
<SegmentationProgress> {
54
55
public
:
56
class
LabellingListener
;
57
class
Labelling
;
58
60
virtual
~Segmentation
() =
default
;
61
62
explicit
Segmentation
(
std::shared_ptr<DetectionImageFrame::ImageFilter>
image_processing
);
63
64
template
<
class
LabellingType
,
typename
...
Args
>
65
void
setLabelling
(
Args
...
args
) {
66
static_assert
(
std::is_base_of<Labelling, LabellingType>::value
,
67
"LabellingType must inherit from SourceXtractor::Segmentation::Labelling"
);
68
static_assert
(
std::is_constructible
<
LabellingType
,
Args
...>::value,
69
"LabellingType must be constructible from args"
);
70
71
m_labelling
.reset(
new
LabellingType
(
std::forward<Args>
(
args
)...));
72
}
73
75
void
processFrame
(
std::shared_ptr<DetectionImageFrame>
frame
)
const
;
76
77
private
:
78
std::unique_ptr<Labelling>
m_labelling
;
79
std::shared_ptr<DetectionImageFrame::ImageFilter>
m_filter_image_processing
;
80
81
};
/* End of Segmentation class */
82
83
class
Segmentation::LabellingListener
{
84
public
:
85
LabellingListener
(
const
Segmentation
&
segmentation
,
std::shared_ptr<DetectionImageFrame>
detection_frame
) :
86
m_segmentation
(
segmentation
),
87
m_detection_frame
(
detection_frame
) {}
88
89
void
publishSource
(
std::unique_ptr<SourceInterface>
source
)
const
{
90
if
(
m_detection_frame
) {
91
source
->setProperty<
DetectionFrame
>(
m_detection_frame
);
92
}
93
m_segmentation
.sendSource(
std::move
(
source
));
94
}
95
96
void
notifyProgress
(
int
position,
int
total) {
97
m_segmentation
.Observable<SegmentationProgress>::notifyObservers(
SegmentationProgress
{position, total});
98
}
99
100
void
requestProcessing
(
const
ProcessSourcesEvent
&
event
) {
101
m_segmentation
.sendProcessSignal(
event
);
102
}
103
104
private
:
105
const
Segmentation
&
m_segmentation
;
106
std::shared_ptr<DetectionImageFrame>
m_detection_frame
;
107
};
108
109
class
Segmentation::Labelling
{
110
public
:
111
virtual
~Labelling
() =
default
;
112
Labelling
() {}
113
114
virtual
void
labelImage
(
Segmentation::LabellingListener
&
listener
,
std::shared_ptr<const DetectionImageFrame>
frame
) = 0;
115
};
116
117
}
/* namespace SourceXtractor */
118
119
#endif
CoordinateSystem.h
DetectionFrame.h
Frame.h
Image.h
PipelineStage.h
SourceGrouping.h
SourceInterface.h
SourceXtractor::DetectionFrame
Definition
DetectionFrame.h:33
SourceXtractor::Observable
Implements the Observer pattern. Notifications will be made using a message of type T.
Definition
Observable.h:51
SourceXtractor::PipelineEmitter
Definition
PipelineStage.h:68
SourceXtractor::Segmentation::LabellingListener
Definition
Segmentation.h:83
SourceXtractor::Segmentation::LabellingListener::requestProcessing
void requestProcessing(const ProcessSourcesEvent &event)
Definition
Segmentation.h:100
SourceXtractor::Segmentation::LabellingListener::m_detection_frame
std::shared_ptr< DetectionImageFrame > m_detection_frame
Definition
Segmentation.h:106
SourceXtractor::Segmentation::LabellingListener::LabellingListener
LabellingListener(const Segmentation &segmentation, std::shared_ptr< DetectionImageFrame > detection_frame)
Definition
Segmentation.h:85
SourceXtractor::Segmentation::LabellingListener::publishSource
void publishSource(std::unique_ptr< SourceInterface > source) const
Definition
Segmentation.h:89
SourceXtractor::Segmentation::LabellingListener::m_segmentation
const Segmentation & m_segmentation
Definition
Segmentation.h:105
SourceXtractor::Segmentation::LabellingListener::notifyProgress
void notifyProgress(int position, int total)
Definition
Segmentation.h:96
SourceXtractor::Segmentation::Labelling
Definition
Segmentation.h:109
SourceXtractor::Segmentation::Labelling::labelImage
virtual void labelImage(Segmentation::LabellingListener &listener, std::shared_ptr< const DetectionImageFrame > frame)=0
SourceXtractor::Segmentation::Labelling::Labelling
Labelling()
Definition
Segmentation.h:112
SourceXtractor::Segmentation::Labelling::~Labelling
virtual ~Labelling()=default
SourceXtractor::Segmentation
Segmentation takes an image and splits it into individual Sources for further refinement....
Definition
Segmentation.h:53
SourceXtractor::Segmentation::setLabelling
void setLabelling(Args... args)
Definition
Segmentation.h:65
SourceXtractor::Segmentation::m_filter_image_processing
std::shared_ptr< DetectionImageFrame::ImageFilter > m_filter_image_processing
Definition
Segmentation.h:79
SourceXtractor::Segmentation::Segmentation
Segmentation(std::shared_ptr< DetectionImageFrame::ImageFilter > image_processing)
Definition
Segmentation.cpp:27
SourceXtractor::Segmentation::processFrame
void processFrame(std::shared_ptr< DetectionImageFrame > frame) const
Processes a Frame notifying Observers with a Source object for each detection.
Definition
Segmentation.cpp:31
SourceXtractor::Segmentation::m_labelling
std::unique_ptr< Labelling > m_labelling
Definition
Segmentation.h:78
SourceXtractor::Segmentation::~Segmentation
virtual ~Segmentation()=default
Destructor.
std::function
std::is_base_of
std::is_constructible
std::move
T move(T... args)
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::ProcessSourcesEvent
Event received by SourceGrouping to request the processing of some of the Sources stored.
Definition
PipelineStage.h:33
SourceXtractor::SegmentationProgress
Used to notify observers of the progress of the processing of the image.
Definition
Segmentation.h:43
SourceXtractor::SegmentationProgress::position
int position
Definition
Segmentation.h:44
SourceXtractor::SegmentationProgress::total
int total
Definition
Segmentation.h:44
Generated by
1.10.0