SourceXtractorPlusPlus
0.13
Please provide a description of the project.
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/Property/DetectionFrame.h
"
30
#include "
SEFramework/Frame/Frame.h
"
31
32
#include "
SEUtils/Observable.h
"
33
#include "
SEFramework/Source/SourceInterface.h
"
34
#include "
SEFramework/Image/Image.h
"
35
#include "
SEFramework/CoordinateSystem/CoordinateSystem.h
"
36
#include "
SEFramework/Frame/Frame.h
"
37
38
#include "
SEFramework/Pipeline/SourceGrouping.h
"
39
40
41
42
namespace
SourceXtractor
{
43
48
struct
SegmentationProgress
{
49
int
position
,
total
;
50
};
51
58
class
Segmentation
:
public
Observable
<std::shared_ptr<SourceInterface>>,
public
Observable
<SegmentationProgress>,
59
public
Observable
<ProcessSourcesEvent> {
60
61
public
:
62
class
LabellingListener
;
63
class
Labelling
;
64
66
virtual
~Segmentation
() =
default
;
67
68
Segmentation
(
std::shared_ptr<DetectionImageFrame::ImageFilter>
image_processing);
69
70
template
<
class
LabellingType,
typename
... Args>
71
void
setLabelling
(Args... args) {
72
static_assert(
std::is_base_of<Labelling, LabellingType>::value
,
73
"LabellingType must inherit from SourceXtractor::Segmentation::Labelling"
);
74
static_assert(
std::is_constructible<LabellingType, Args...>::value
,
75
"LabellingType must be constructible from args"
);
76
77
m_labelling
.reset(
new
LabellingType(std::forward<Args>(args)...));
78
}
79
81
void
processFrame
(
std::shared_ptr<DetectionImageFrame>
frame)
const
;
82
83
protected
:
84
void
publishSource
(
std::shared_ptr<SourceInterface>
source)
const
{
85
Observable<std::shared_ptr<SourceInterface>
>
::notifyObservers
(source);
86
}
87
88
private
:
89
std::unique_ptr<Labelling>
m_labelling
;
90
std::shared_ptr<DetectionImageFrame::ImageFilter>
m_filter_image_processing
;
91
92
};
/* End of Segmentation class */
93
94
class
Segmentation::LabellingListener
{
95
public
:
96
LabellingListener
(
const
Segmentation
& segmentation,
std::shared_ptr<DetectionImageFrame>
detection_frame) :
97
m_segmentation
(segmentation),
98
m_detection_frame
(detection_frame) {}
99
100
void
publishSource
(
std::shared_ptr<SourceInterface>
source)
const
{
101
source->setProperty<
DetectionFrame
>(
m_detection_frame
);
102
m_segmentation
.Observable<
std::shared_ptr<SourceInterface>
>
::notifyObservers
(source);
103
}
104
105
void
notifyProgress
(
int
position,
int
total) {
106
m_segmentation
.Observable<SegmentationProgress>::notifyObservers(
SegmentationProgress
{position, total});
107
}
108
109
void
requestProcessing
(
const
ProcessSourcesEvent
& event) {
110
m_segmentation
.Observable<ProcessSourcesEvent>::notifyObservers(event);
111
}
112
113
private
:
114
const
Segmentation
&
m_segmentation
;
115
std::shared_ptr<DetectionImageFrame>
m_detection_frame
;
116
};
117
118
class
Segmentation::Labelling
{
119
public
:
120
virtual
~Labelling
() =
default
;
121
Labelling
() {}
122
123
virtual
void
labelImage
(
Segmentation::LabellingListener
& listener,
std::shared_ptr<const DetectionImageFrame>
frame) = 0;
124
};
125
126
}
/* namespace SourceXtractor */
127
128
#endif
SourceXtractor::Observable< ProcessSourcesEvent >::notifyObservers
void notifyObservers(const ProcessSourcesEvent &message) const
Definition:
Observable.h:71
std::shared_ptr
STL class.
SourceXtractor::ProcessSourcesEvent
Event received by SourceGrouping to request the processing of some of the Sources stored.
Definition:
SourceGrouping.h:71
SourceXtractor::Segmentation::Labelling
Definition:
Segmentation.h:118
SourceGrouping.h
SourceInterface.h
SourceXtractor::Segmentation::publishSource
void publishSource(std::shared_ptr< SourceInterface > source) const
Definition:
Segmentation.h:84
SourceXtractor::Segmentation::m_labelling
std::unique_ptr< Labelling > m_labelling
Definition:
Segmentation.h:89
SourceXtractor::Segmentation::LabellingListener::publishSource
void publishSource(std::shared_ptr< SourceInterface > source) const
Definition:
Segmentation.h:100
SourceXtractor::SegmentationProgress::total
int total
Definition:
Segmentation.h:49
DetectionFrame.h
CoordinateSystem.h
SourceXtractor::Segmentation::Labelling::labelImage
virtual void labelImage(Segmentation::LabellingListener &listener, std::shared_ptr< const DetectionImageFrame > frame)=0
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
Definition:
Aperture.h:30
SourceXtractor::Segmentation::LabellingListener::LabellingListener
LabellingListener(const Segmentation &segmentation, std::shared_ptr< DetectionImageFrame > detection_frame)
Definition:
Segmentation.h:96
SourceXtractor::Segmentation::Segmentation
Segmentation(std::shared_ptr< DetectionImageFrame::ImageFilter > image_processing)
Definition:
Segmentation.cpp:27
SourceXtractor::DetectionFrame
Definition:
DetectionFrame.h:33
SourceXtractor::Segmentation::LabellingListener::m_detection_frame
std::shared_ptr< DetectionImageFrame > m_detection_frame
Definition:
Segmentation.h:115
Image.h
Observable.h
Frame.h
SourceXtractor::Segmentation::~Segmentation
virtual ~Segmentation()=default
Destructor.
SourceXtractor::Observable
Implements the Observer pattern. Notifications will be made using a message of type T.
Definition:
Observable.h:51
SourceXtractor::Segmentation::LabellingListener
Definition:
Segmentation.h:94
SourceXtractor::Segmentation::LabellingListener::m_segmentation
const Segmentation & m_segmentation
Definition:
Segmentation.h:114
SourceXtractor::Segmentation::LabellingListener::requestProcessing
void requestProcessing(const ProcessSourcesEvent &event)
Definition:
Segmentation.h:109
SourceXtractor::Segmentation::setLabelling
void setLabelling(Args... args)
Definition:
Segmentation.h:71
SourceXtractor::Segmentation::Labelling::Labelling
Labelling()
Definition:
Segmentation.h:121
std::is_constructible
SourceXtractor::Segmentation::Labelling::~Labelling
virtual ~Labelling()=default
SourceXtractor::Segmentation::LabellingListener::notifyProgress
void notifyProgress(int position, int total)
Definition:
Segmentation.h:105
std::unique_ptr
STL class.
SourceXtractor::Segmentation
Segmentation takes an image and splits it into individual Sources for further refinement....
Definition:
Segmentation.h:59
SourceXtractor::SegmentationProgress::position
int position
Definition:
Segmentation.h:49
SourceXtractor::SegmentationProgress
Used to notify observers of the progress of the processing of the image.
Definition:
Segmentation.h:48
std::is_base_of
SourceXtractor::Segmentation::m_filter_image_processing
std::shared_ptr< DetectionImageFrame::ImageFilter > m_filter_image_processing
Definition:
Segmentation.h:90
Generated by
1.8.20