DepthImageExtractor.cpp
Go to the documentation of this file.
2
4{
5 void
7 {
9
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 && shape[2] == 4 &&
18 std::accumulate(std::begin(shape), std::end(shape), 1, std::multiplies<int>()) >
19 200) // must be big enough to assume an image (instead of 4x4x4 poses)
20 {
21 depthImages[key] = ndarray;
22 dict->setElement(key, nullptr);
23 }
24 }
25 }
26 }
27
28 void
30 {
31 // A member is null. Simply ignore...
32 }
33
36 {
38 aron::data::VariantPtr var = std::static_pointer_cast<aron::data::Variant>(data);
40 aron::data::visitRecursive(visitor, var);
41
42 ExtractionResult encoding;
43 encoding.dataWithoutExtraction = data;
44 encoding.extraction = visitor.depthImages;
45 return encoding;
46 }
47
50 {
51 return encoding.dataWithoutExtraction;
52 }
53} // namespace armarx::armem::server::ltm::processor::extractor
aron::data::DictPtr merge(ExtractionResult &encoding) override
ExtractionResult extract(aron::data::DictPtr &data) override
#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...
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
std::shared_ptr< Variant > VariantPtr
void visitRecursive(RecursiveVisitorImplementation &v, typename RecursiveVisitorImplementation::Input &o)
std::map< std::string, aron::data::VariantPtr > extraction
Definition Extractor.h:21
typename VisitorBase< data::VariantPtr >::Input Input