ImageExtractor.cpp
Go to the documentation of this file.
1
#include "
ImageExtractor.h
"
2
3
namespace
armarx::armem::server::ltm::processor::extractor
4
{
5
void
6
ImageExtractorVisitor::visitDictOnEnter
(
Input
&
data
)
7
{
8
ARMARX_CHECK_NOT_NULL
(
data
);
9
10
auto
dict =
aron::data::Dict::DynamicCastAndCheck
(
data
);
11
for
(
const
auto
& [key, child] : dict->getElements())
12
{
13
if
(child && child->getDescriptor() ==
aron::data::Descriptor::NDARRAY
)
14
{
15
auto
ndarray =
aron::data::NDArray::DynamicCastAndCheck
(child);
16
auto
shape = ndarray->getShape();
17
if
(shape.size() == 3 &&
18
(shape[2] == 3 || shape[2] == 1
/* 3 channel color or grayscale */
) &&
19
std::accumulate(std::begin(shape), std::end(shape), 1, std::multiplies<int>()) >
20
200)
// must be big enough to assume an image (instead of 4x4x4 poses)
21
{
22
images
[key] = ndarray;
23
dict->setElement(key,
nullptr
);
24
}
25
}
26
}
27
}
28
29
void
30
ImageExtractorVisitor::visitUnknown
(
Input
&)
31
{
32
// A member is null. Simply ignore...
33
}
34
35
Extractor::ExtractionResult
36
ImageExtractor::extract
(
aron::data::DictPtr
&
data
)
37
{
38
ImageExtractorVisitor
visitor;
39
aron::data::VariantPtr
var = std::static_pointer_cast<aron::data::Variant>(
data
);
40
aron::data::VariantPtr
p;
41
aron::data::visitRecursive
(visitor, var);
42
43
ExtractionResult
encoding;
44
encoding.
dataWithoutExtraction
=
data
;
45
encoding.
extraction
= visitor.
images
;
46
return
encoding;
47
}
48
49
aron::data::DictPtr
50
ImageExtractor::merge
(
ExtractionResult
& encoding)
51
{
52
return
encoding.
dataWithoutExtraction
;
53
}
54
}
// namespace armarx::armem::server::ltm::extractor
armarx::armem::server::ltm::processor::extractor::ImageExtractorVisitor::visitDictOnEnter
void visitDictOnEnter(Input &data)
Definition:
ImageExtractor.cpp:6
armarx::aron::data::Descriptor::NDARRAY
@ NDARRAY
armarx::armem::server::ltm::processor::Extractor::ExtractionResult::dataWithoutExtraction
aron::data::DictPtr dataWithoutExtraction
Definition:
Extractor.h:20
armarx::armem::server::ltm::processor::extractor
Definition:
DepthImageExtractor.cpp:4
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition:
ExpressionException.h:206
armarx::armem::server::ltm::processor::extractor::ImageExtractorVisitor::visitUnknown
void visitUnknown(Input &data)
Definition:
ImageExtractor.cpp:30
armarx::aron::data::RecursiveVisitor< data::VariantPtr >::Input
typename VisitorBase< data::VariantPtr >::Input Input
Definition:
RecursiveVisitor.h:39
armarx::aron::data::detail::SpecializedVariantBase< data::dto::Dict, Dict >::DynamicCastAndCheck
static PointerType DynamicCastAndCheck(const VariantPtr &n)
Definition:
SpecializedVariant.h:135
armarx::aron::data::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition:
forward_declarations.h:11
armarx::armem::server::ltm::processor::extractor::ImageExtractorVisitor
Definition:
ImageExtractor.h:10
data
uint8_t data[1]
Definition:
EtherCATFrame.h:68
armarx::armem::server::ltm::processor::Extractor::ExtractionResult
Definition:
Extractor.h:18
armarx::armem::server::ltm::processor::extractor::ImageExtractor::merge
aron::data::DictPtr merge(ExtractionResult &encoding) override
Definition:
ImageExtractor.cpp:50
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition:
Dict.h:41
armarx::armem::server::ltm::processor::Extractor::ExtractionResult::extraction
std::map< std::string, aron::data::VariantPtr > extraction
Definition:
Extractor.h:21
armarx::aron::data::visitRecursive
requires isRecursiveVisitor< RecursiveVisitorImplementation, typename RecursiveVisitorImplementation::Input > void visitRecursive(RecursiveVisitorImplementation &v, typename RecursiveVisitorImplementation::Input &o)
Definition:
RecursiveVisitor.h:146
ImageExtractor.h
armarx::armem::server::ltm::processor::extractor::ImageExtractor::extract
ExtractionResult extract(aron::data::DictPtr &data) override
Definition:
ImageExtractor.cpp:36
armarx::armem::server::ltm::processor::extractor::ImageExtractorVisitor::images
std::map< std::string, aron::data::VariantPtr > images
Definition:
ImageExtractor.h:13
RobotAPI
libraries
armem
server
ltm
processors
extractor
imageExtractor
ImageExtractor.cpp
Generated on Sat Oct 12 2024 09:14:08 for armarx_documentation by
1.8.17