ImagesProperties.cpp
Go to the documentation of this file.
1 #include "ImagesProperties.h"
2 
3 #include <SimoxUtility/algorithm/string.h>
4 
7 
8 namespace visionx::armem_images
9 {
10 
11  void
13  {
15  "img.rgb.EntityID",
16  rgbEntityID.str(),
17  "The RGB image(s) entity ID. Provider segment name can be set via 'img.ProviderName'.");
18  defs.defineOptionalProperty("img.rgb.ImageIndices",
19  simox::alg::join(simox::alg::multi_to_string(rgbIndices)),
20  "Indices of RGB images in provided images");
21 
22  defs.defineOptionalProperty("img.depth.EntityID",
24  "The depth image(s) entity ID. Provider segment name can be "
25  "set via 'img.ProviderName'.");
26  defs.defineOptionalProperty("img.depth.ImageIndices",
27  simox::alg::join(simox::alg::multi_to_string(depthIndices)),
28  "Indices of Depth images in provided images.");
29  }
30 
31  void
33  const std::string& defaultProviderSegmentName)
34  {
35  // Parse properties.
36  rgbEntityID = getEntityID(properties, "img.rgb.EntityID", defaultProviderSegmentName);
37  depthEntityID = getEntityID(properties, "img.depth.EntityID", defaultProviderSegmentName);
38 
39  rgbIndices = getIndices(properties, "img.rgb.ImageIndices");
40  depthIndices = getIndices(properties, "img.depth.ImageIndices");
41  }
42 
45  const std::string& propertyName,
46  const std::string& defaultProviderSegmentName)
47  {
48  armarx::armem::MemoryID id(properties.getProperty<std::string>(propertyName));
49  if (!id.hasProviderSegmentName())
50  {
51  id.providerSegmentName = defaultProviderSegmentName;
52  }
53  return id;
54  }
55 
56  std::vector<size_t>
57  ImagesProperties::getIndices(armarx::PropertyUser& properties, const std::string& propertyName)
58  {
59  std::string prop = properties.getProperty<std::string>(propertyName);
60  std::vector<size_t> indices;
61  if (prop.empty())
62  {
63  return indices;
64  }
65 
66  std::vector<std::string> indicesStr = simox::alg::split(prop, ",", true, true);
67  std::transform(indicesStr.begin(),
68  indicesStr.end(),
69  std::back_inserter(indices),
70  [](const std::string& s)
71  {
72  long l = std::stol(s);
73  ARMARX_CHECK_NONNEGATIVE(l) << "Image indices must be non-negative.";
74  return static_cast<size_t>(l);
75  });
76  return indices;
77  }
78 } // namespace visionx::armem_images
visionx::armem_images::ImagesProperties::rgbIndices
std::vector< size_t > rgbIndices
Definition: ImagesProperties.h:31
visionx::armem_images::ImagesProperties::depthIndices
std::vector< size_t > depthIndices
Definition: ImagesProperties.h:32
armarx::PropertyDefinitionContainer::defineOptionalProperty
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Definition: PropertyDefinitionContainer.h:533
armarx::armem::MemoryID::str
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Definition: MemoryID.cpp:102
ImagesProperties.h
visionx::armem_images::ImagesProperties::getIndices
static std::vector< size_t > getIndices(armarx::PropertyUser &properties, const std::string &propertyName)
Definition: ImagesProperties.cpp:57
visionx::armem_images
Definition: ImageReader.cpp:29
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
pcl::graph::indices
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
Definition: point_cloud_graph.h:717
PropertyUser.h
visionx::armem_images::ImagesProperties::define
void define(armarx::PropertyDefinitionContainer &defs)
Definition: ImagesProperties.cpp:12
armarx::PropertyDefinitionContainer
PropertyDefinitionContainer.
Definition: PropertyDefinitionContainer.h:53
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT >>
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:351
PropertyDefinitionContainer.h
armarx::PropertyUser::getProperty
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
Definition: PropertyUser.h:180
visionx::armem_images::ImagesProperties::read
void read(armarx::PropertyUser &properties, const std::string &defaultProviderSegmentName)
Definition: ImagesProperties.cpp:32
visionx::armem_images::ImagesProperties::rgbEntityID
armarx::armem::MemoryID rgbEntityID
Definition: ImagesProperties.h:28
visionx::armem_images::ImagesProperties::getEntityID
static armarx::armem::MemoryID getEntityID(armarx::PropertyUser &properties, const std::string &propertyName, const std::string &defaultProviderSegmentName)
Definition: ImagesProperties.cpp:44
armarx::PropertyUser
Abstract PropertyUser class.
Definition: PropertyUser.h:63
visionx::armem_images::ImagesProperties::depthEntityID
armarx::armem::MemoryID depthEntityID
Definition: ImagesProperties.h:29
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:38