ImagesProperties.cpp
Go to the documentation of this file.
1 #include "ImagesProperties.h"
2 
3 #include <SimoxUtility/algorithm/string.h>
4 
7 
8 
9 namespace visionx::armem_images
10 {
11 
13  {
14  defs.defineOptionalProperty("img.rgb.EntityID", rgbEntityID.str(),
15  "The RGB image(s) entity ID. Provider segment name can be set via 'img.ProviderName'.");
16  defs.defineOptionalProperty("img.rgb.ImageIndices", simox::alg::join(simox::alg::multi_to_string(rgbIndices)),
17  "Indices of RGB images in provided images");
18 
19  defs.defineOptionalProperty("img.depth.EntityID", depthEntityID.str(),
20  "The depth image(s) entity ID. Provider segment name can be set via 'img.ProviderName'.");
21  defs.defineOptionalProperty("img.depth.ImageIndices", simox::alg::join(simox::alg::multi_to_string(depthIndices)),
22  "Indices of Depth images in provided images.");
23  }
24 
25 
26  void ImagesProperties::read(armarx::PropertyUser& properties, const std::string& defaultProviderSegmentName)
27  {
28  // Parse properties.
29  rgbEntityID = getEntityID(properties, "img.rgb.EntityID", defaultProviderSegmentName);
30  depthEntityID = getEntityID(properties, "img.depth.EntityID", defaultProviderSegmentName);
31 
32  rgbIndices = getIndices(properties, "img.rgb.ImageIndices");
33  depthIndices = getIndices(properties, "img.depth.ImageIndices");
34  }
35 
36 
38  ImagesProperties::getEntityID(armarx::PropertyUser& properties, const std::string& propertyName, const std::string& defaultProviderSegmentName)
39  {
40  armarx::armem::MemoryID id(properties.getProperty<std::string>(propertyName));
41  if (!id.hasProviderSegmentName())
42  {
43  id.providerSegmentName = defaultProviderSegmentName;
44  }
45  return id;
46  }
47 
48 
49  std::vector<size_t> ImagesProperties::getIndices(armarx::PropertyUser& properties, const std::string& propertyName)
50  {
51  std::string prop = properties.getProperty<std::string>(propertyName);
52  std::vector<size_t> indices;
53  if (prop.empty())
54  {
55  return indices;
56  }
57 
58  std::vector<std::string> indicesStr = simox::alg::split(prop, ",", true, true);
59  std::transform(indicesStr.begin(), indicesStr.end(), std::back_inserter(indices), [](const std::string & s)
60  {
61  long l = std::stol(s);
62  ARMARX_CHECK_NONNEGATIVE(l) << "Image indices must be non-negative.";
63  return static_cast<size_t>(l);
64  });
65  return indices;
66  }
67 }
68 
visionx::armem_images::ImagesProperties::rgbIndices
std::vector< size_t > rgbIndices
Definition: ImagesProperties.h:33
visionx::armem_images::ImagesProperties::depthIndices
std::vector< size_t > depthIndices
Definition: ImagesProperties.h:34
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:49
visionx::armem_images
Definition: ImageReader.cpp:25
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:737
PropertyUser.h
visionx::armem_images::ImagesProperties::define
void define(armarx::PropertyDefinitionContainer &defs)
Definition: ImagesProperties.cpp:12
armarx::PropertyDefinitionContainer
PropertyDefinitionContainer.
Definition: PropertyDefinitionContainer.h:53
PropertyDefinitionContainer.h
armarx::PropertyUser::getProperty
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
Definition: PropertyUser.h:179
visionx::armem_images::ImagesProperties::read
void read(armarx::PropertyUser &properties, const std::string &defaultProviderSegmentName)
Definition: ImagesProperties.cpp:26
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:315
visionx::armem_images::ImagesProperties::rgbEntityID
armarx::armem::MemoryID rgbEntityID
Definition: ImagesProperties.h:30
visionx::armem_images::ImagesProperties::getEntityID
static armarx::armem::MemoryID getEntityID(armarx::PropertyUser &properties, const std::string &propertyName, const std::string &defaultProviderSegmentName)
Definition: ImagesProperties.cpp:38
armarx::PropertyUser
Abstract PropertyUser class.
Definition: PropertyUser.h:62
visionx::armem_images::ImagesProperties::depthEntityID
armarx::armem::MemoryID depthEntityID
Definition: ImagesProperties.h:31
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:36