DepthImageExtractor.cpp
Go to the documentation of this file.
1 #include "DepthImageExtractor.h"
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
armarx::armem::server::ltm::processor::extractor::DepthImageExtractor::merge
aron::data::DictPtr merge(ExtractionResult &encoding) override
Definition: DepthImageExtractor.cpp:49
armarx::aron::data::Descriptor::NDARRAY
@ NDARRAY
armarx::armem::server::ltm::processor::extractor::DepthImageExtractorVisitor
Definition: DepthImageExtractor.h:10
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:3
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::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:134
armarx::armem::server::ltm::processor::extractor::DepthImageExtractorVisitor::visitDictOnEnter
void visitDictOnEnter(Input &data)
Definition: DepthImageExtractor.cpp:6
armarx::aron::data::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::armem::server::ltm::processor::extractor::DepthImageExtractor::extract
ExtractionResult extract(aron::data::DictPtr &data) override
Definition: DepthImageExtractor.cpp:35
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::armem::server::ltm::processor::extractor::DepthImageExtractorVisitor::depthImages
std::map< std::string, aron::data::VariantPtr > depthImages
Definition: DepthImageExtractor.h:13
armarx::armem::server::ltm::processor::Extractor::ExtractionResult
Definition: Extractor.h:18
DepthImageExtractor.h
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::armem::server::ltm::processor::extractor::DepthImageExtractorVisitor::visitUnknown
void visitUnknown(Input &data)
Definition: DepthImageExtractor.cpp:29
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:161