4#include <unordered_set>
15#include <VisionX/libraries/armem/vision/camera/core/aron/CameraCalibration.aron.generated.h>
19#include <Image/ByteImage.h>
20#include <Image/ImageProcessor.h>
29 template <
class AronImageT>
32 const std::vector<size_t>& imageIndices)
36 for (
size_t i = 0; i < imageIndices.size(); ++i)
41 size_t index = imageIndices[i];
60 const std::vector<size_t>& imageIndices)
62 if (imageIndices.empty())
67 addImages<arondto::ImageRGB>(entityID, imageIndices);
76 const std::vector<size_t>& imageIndices)
78 if (imageIndices.empty())
83 addImages<arondto::ImageDepth>(entityID, imageIndices);
98 <<
"Currently, all images must be from the same memory.";
101 <<
"Currently, all images must be from the same provider.";
106 armarx::armem::data::AddSegmentsInput
109 std::unordered_set<armarx::armem::MemoryID> providerIDs;
114 armarx::armem::data::AddSegmentsInput inputs;
117 armarx::armem::data::AddSegmentInput& input = inputs.emplace_back();
118 input.coreSegmentName =
id.coreSegmentName;
119 input.providerSegmentName =
id.providerSegmentName;
120 input.clearWhenExists = clearWhenExists;
125 armarx::armem::data::AddSegmentsResult
129 const armarx::armem::data::AddSegmentsResult results =
memoryWriter.addSegments(inputs);
132 for (
size_t i = 0; i < results.size(); ++i)
134 if (!results.at(i).success)
136 const armarx::armem::data::AddSegmentInput& in = inputs.at(i);
137 ARMARX_ERROR <<
"Failed to add provider segment '" << in.coreSegmentName <<
"/"
138 << in.providerSegmentName <<
"'."
140 << results.at(0).errorMessage;
152 for (std::unique_ptr<ImageBase>& image : images)
154 image->usePixels(inputImageBuffer);
165 for (std::unique_ptr<ImageBase>& image : images)
167 image->usePixels(inputImageBuffers);
182 update.entityID = entityID;
184 for (
const auto& image : images)
186 update.instancesData.push_back(image->toAron());
197 ARMARX_DEBUG <<
"Got a new image for processing. Sending images to vision memory.";
209 std::stringstream ss;
210 for (
size_t i = 0; i < results.
results.size(); ++i)
212 ss <<
"\n- " << commit.
updates.at(i).entityID <<
": \n" << results.
results.at(i);
231 visionx::arondto::StereoCameraCalibration aron;
251 if (not result.allSuccess())
253 ARMARX_ERROR <<
"An error occured when sending pointclouds to the memory. "
254 "Try to continue with next PC. The message was: "
255 << result.allErrorMessages();
262 visionx::arondto::MonocularCameraCalibration aron;
282 if (not result.allSuccess())
284 ARMARX_ERROR <<
"An error occured when sending pointclouds to the memory. "
285 "Try to continue with next PC. The message was: "
286 << result.allErrorMessages();
293 std::stringstream ss;
296 ss <<
"- Entity " << entityID <<
": \n";
297 for (
const auto& image : images)
299 ss <<
"- - [image #" << image->imageIndex <<
"] id = " << image->instanceID <<
"\n";
310 for (
auto& image : images)
312 image->resetImage(height, width);
322 for (
auto& image : images)
324 image->resetImage(info.dimension.height, info.dimension.width);
329 std::vector<CByteImage>
332 std::vector<CByteImage> buffer;
335 for (
auto& image : images)
337 if (image->imageIndex >= buffer.size())
339 buffer.resize(image->imageIndex + 1);
341 cv::Mat& mat = image->getImage();
342 buffer[image->imageIndex].Set(mat.cols, mat.rows, CByteImage::eRGB24);
The Variant class is described here: Variants.
MemoryID getProviderSegmentID() const
Helps a memory client sending data to a memory.
void useImageBuffers(CByteImage **inputImageBuffer, armarx::armem::Time timeProvided)
Store image data from the given buffer.
armarx::armem::Time timestamp
void initImages(int width, int height, CByteImage::ImageType type)
std::string summarizeStructure() const override
std::vector< CByteImage > makeCByteImageBuffer()
armarx::armem::Commit makeCommit() const
Build the commit.
armarx::armem::MemoryID getMemoryID() const override
void usePixelBuffers(void **inputImageBuffer, armarx::armem::Time timeProvided)
armarx::armem::client::Writer memoryWriter
void addImagesDepth(const armarx::armem::MemoryID &entityID, const std::vector< size_t > &imageIndices) override
void commitImages()
Commit the stored image data.
void setWritingMemory(armarx::armem::server::WritingMemoryInterfacePrx memory)
armarx::armem::data::AddSegmentsInput makeAddSegmentsInput(bool clearWhenExists=true)
Build inputs for adding the required provider segments.
void addImagesRGB(const armarx::armem::MemoryID &entityID, const std::vector< size_t > &imageIndices) override
void setWriter(const armarx::armem::client::Writer &writer)
armarx::armem::data::AddSegmentsResult addProviderSegments(bool clearWhenExists=true, int verbose=1)
Add the required provider segments.
std::map< armarx::armem::MemoryID, std::vector< std::unique_ptr< ImageBase > > > imagesByEntity
Entity ID to memory images (instances).
void commitCameraCalibration(const visionx::StereoCalibration &)
Calibration.
A class template implementing the interface defined by ImageBase for a specific aron-generated class.
std::string debugObserverChannelName
armarx::DebugObserverInterfacePrx debugObserver
ImageAdapter(const std::string &debugObserverChannelName="ImageAdapter")
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_VERBOSE
The logging level for verbose information.
#define TIMING_START(name)
Helper macro to do timing tests.
#define TIMING_END_STREAM(name, os)
Prints duration.
armarx::core::time::DateTime Time
const constexpr char * MONOCULAR_CAMERA_CALIBRATION_CORE_SEGMENT_NAME
const constexpr char * STEREO_CAMERA_CALIBRATION_CORE_SEGMENT_NAME
const constexpr char * ENTITY_NAME
void fromIce(visionx::arondto::CameraParameters &aron, const visionx::CameraParameters &ice)
std::vector< EntityUpdateResult > results
A bundle of updates to be sent to the memory.
std::vector< EntityUpdate > updates
The entity updates.
An update of an entity for a specific point in time.
float confidence
An optional confidence, may be used for things like decay.
MemoryID entityID
The entity's ID.
Time referencedTime
Time when this entity update was created (e.g.
std::vector< aron::data::DictPtr > instancesData
The entity data.
Time sentTime
Time when this update was sent to the memory server.