ImageToArMem.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <vector>
6 
11 
12 #include <VisionX/interface/components/Calibration.h>
15 
16 namespace visionx::armem_images
17 {
18 
19  /**
20  * @brief Allows to convert multiple CByteImages to Aron images and
21  * memory commits.
22  */
24  {
25  public:
26  ImageToArMem();
27 
28  void setWritingMemory(armarx::armem::server::WritingMemoryInterfacePrx memory);
29  void setWriter(const armarx::armem::client::Writer& writer);
30 
31  void addImagesRGB(const armarx::armem::MemoryID& entityID,
32  const std::vector<size_t>& imageIndices) override;
33  void addImagesDepth(const armarx::armem::MemoryID& entityID,
34  const std::vector<size_t>& imageIndices) override;
35 
36  armarx::armem::MemoryID getMemoryID() const override;
37  std::string summarizeStructure() const override;
38 
39  void initImages(int width, int height, CByteImage::ImageType type);
40  void initImages(const visionx::ImageFormatInfo& info);
41  std::vector<CByteImage> makeCByteImageBuffer();
42 
43 
44  /// Build inputs for adding the required provider segments.
45  armarx::armem::data::AddSegmentsInput makeAddSegmentsInput(bool clearWhenExists = true);
46  /// Add the required provider segments.
47  armarx::armem::data::AddSegmentsResult addProviderSegments(bool clearWhenExists = true,
48  int verbose = 1);
49 
50 
51  /// Store image data from the given buffer.
52  void useImageBuffers(CByteImage** inputImageBuffer, armarx::armem::Time timeProvided);
53  void usePixelBuffers(void** inputImageBuffer, armarx::armem::Time timeProvided);
54 
55  /// Build the commit.
57  /// Commit the stored image data.
58  void commitImages();
59 
60  /// Calibration
61  void commitCameraCalibration(const visionx::StereoCalibration&);
62  void commitCameraCalibration(const visionx::MonocularCalibration&);
63 
64 
65  private:
66  template <class AronImageT>
67  void addImages(const armarx::armem::MemoryID& entityID,
68  const std::vector<size_t>& imageIndices);
69 
70  void updateAronImages(const armarx::armem::wm::Memory& memory);
71 
72 
73  public:
75 
76  /// Entity ID to memory images (instances).
77  std::map<armarx::armem::MemoryID, std::vector<std::unique_ptr<ImageBase>>> imagesByEntity;
79  };
80 
81 } // namespace visionx::armem_images
visionx::armem_images::ImageToArMem::summarizeStructure
std::string summarizeStructure() const override
Definition: ImageToArMem.cpp:291
visionx::armem_images::ImageToArMem::initImages
void initImages(int width, int height, CByteImage::ImageType type)
Definition: ImageToArMem.cpp:306
Writer.h
ImageAdapter.h
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
visionx::armem_images::ImageToArMem::addImagesRGB
void addImagesRGB(const armarx::armem::MemoryID &entityID, const std::vector< size_t > &imageIndices) override
Definition: ImageToArMem.cpp:59
visionx::armem_images::ImageToArMem::useImageBuffers
void useImageBuffers(CByteImage **inputImageBuffer, armarx::armem::Time timeProvided)
Store image data from the given buffer.
Definition: ImageToArMem.cpp:148
MemoryID.h
Image.h
forward_declarations.h
visionx::armem_images::ImageToArMem::setWritingMemory
void setWritingMemory(armarx::armem::server::WritingMemoryInterfacePrx memory)
Definition: ImageToArMem.cpp:47
visionx::armem_images::ImageToArMem::makeCommit
armarx::armem::Commit makeCommit() const
Build the commit.
Definition: ImageToArMem.cpp:174
visionx::armem_images::ImageToArMem::memoryWriter
armarx::armem::client::Writer memoryWriter
Definition: ImageToArMem.h:74
visionx::armem_images::ImageToArMem::getMemoryID
armarx::armem::MemoryID getMemoryID() const override
Definition: ImageToArMem.cpp:91
visionx::armem_images::ImageToArMem::makeAddSegmentsInput
armarx::armem::data::AddSegmentsInput makeAddSegmentsInput(bool clearWhenExists=true)
Build inputs for adding the required provider segments.
Definition: ImageToArMem.cpp:107
visionx::armem_images::ImageToArMem::usePixelBuffers
void usePixelBuffers(void **inputImageBuffer, armarx::armem::Time timeProvided)
Definition: ImageToArMem.cpp:161
visionx::armem_images
Definition: ImageReader.cpp:29
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
visionx::armem_images::ImageToArMem::ImageToArMem
ImageToArMem()
Definition: ImageToArMem.cpp:25
visionx::armem_images::ImageToArMem::addProviderSegments
armarx::armem::data::AddSegmentsResult addProviderSegments(bool clearWhenExists=true, int verbose=1)
Add the required provider segments.
Definition: ImageToArMem.cpp:126
visionx::armem_images::ImageToArMem::makeCByteImageBuffer
std::vector< CByteImage > makeCByteImageBuffer()
Definition: ImageToArMem.cpp:330
armarx::armem::wm::Memory
Client-side working memory.
Definition: memory_definitions.h:133
armarx::armem::client::Writer
Helps a memory client sending data to a memory.
Definition: Writer.h:22
visionx::armem_images::ImageToArMem::timestamp
armarx::armem::Time timestamp
Definition: ImageToArMem.h:78
visionx::armem_images::ImageToArMem::addImagesDepth
void addImagesDepth(const armarx::armem::MemoryID &entityID, const std::vector< size_t > &imageIndices) override
Definition: ImageToArMem.cpp:75
visionx::armem_images::ImageToArMem::imagesByEntity
std::map< armarx::armem::MemoryID, std::vector< std::unique_ptr< ImageBase > > > imagesByEntity
Entity ID to memory images (instances).
Definition: ImageToArMem.h:77
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
visionx::armem_images::ImageToArMem::commitCameraCalibration
void commitCameraCalibration(const visionx::StereoCalibration &)
Calibration.
Definition: ImageToArMem.cpp:229
visionx::armem_images::ImageToArMem
Allows to convert multiple CByteImages to Aron images and memory commits.
Definition: ImageToArMem.h:23
Time.h
visionx::armem_images::detail::ImageAdapter
Definition: ImageAdapter.h:13
visionx::armem_images::ImageToArMem::commitImages
void commitImages()
Commit the stored image data.
Definition: ImageToArMem.cpp:194
visionx::armem_images::ImageToArMem::setWriter
void setWriter(const armarx::armem::client::Writer &writer)
Definition: ImageToArMem.cpp:53