Go to the documentation of this file.
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
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);
std::string summarizeStructure() const override
The Variant class is described here: Variants.
#define TIMING_START(name)
void initImages(int width, int height, CByteImage::ImageType type)
std::vector< aron::data::DictPtr > instancesData
The entity data.
A bundle of updates to be sent to the memory.
const constexpr char * MONOCULAR_CAMERA_CALIBRATION_CORE_SEGMENT_NAME
void addImagesRGB(const armarx::armem::MemoryID &entityID, const std::vector< size_t > &imageIndices) override
std::string debugObserverChannelName
void useImageBuffers(CByteImage **inputImageBuffer, armarx::armem::Time timeProvided)
Store image data from the given buffer.
void setWritingMemory(server::WritingMemoryInterfacePrx memory)
const constexpr char * ENTITY_NAME
float confidence
An optional confidence, may be used for things like decay.
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
void setWritingMemory(armarx::armem::server::WritingMemoryInterfacePrx memory)
armarx::armem::Commit makeCommit() const
Build the commit.
armarx::armem::client::Writer memoryWriter
armarx::armem::MemoryID getMemoryID() const override
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define TIMING_END_STREAM(name, os)
data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input) const
std::vector< EntityUpdate > updates
The entity updates.
armarx::armem::data::AddSegmentsInput makeAddSegmentsInput(bool clearWhenExists=true)
Build inputs for adding the required provider segments.
void fromIce(visionx::arondto::CameraParameters &aron, const visionx::CameraParameters &ice)
void usePixelBuffers(void **inputImageBuffer, armarx::armem::Time timeProvided)
armarx::DebugObserverInterfacePrx debugObserver
armarx::armem::data::AddSegmentsResult addProviderSegments(bool clearWhenExists=true, int verbose=1)
Add the required provider segments.
ReaderT::InputType & input
std::vector< CByteImage > makeCByteImageBuffer()
An update of an entity for a specific point in time.
Helps a memory client sending data to a memory.
CommitResult commit(const Commit &commit) const
Writes a Commit to the memory.
armarx::armem::Time timestamp
void addImagesDepth(const armarx::armem::MemoryID &entityID, const std::vector< size_t > &imageIndices) override
MemoryID getProviderSegmentID() const
std::map< armarx::armem::MemoryID, std::vector< std::unique_ptr< ImageBase > > > imagesByEntity
Entity ID to memory images (instances).
const constexpr char * STEREO_CAMERA_CALIBRATION_CORE_SEGMENT_NAME
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Represents a point in time.
Time referencedTime
Time when this entity update was created (e.g.
std::vector< EntityUpdateResult > results
const std::string memoryName
A class template implementing the interface defined by ImageBase for a specific aron-generated class.
void commitCameraCalibration(const visionx::StereoCalibration &)
Calibration.
#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...
void commitImages()
Commit the stored image data.
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
MemoryID entityID
The entity's ID.
Time sentTime
Time when this update was sent to the memory server.
void setWriter(const armarx::armem::client::Writer &writer)
const armem::MemoryID MemoryID