27 #include <opencv2/highgui.hpp>
52 mid.memoryName = properties().memoryName;
53 mid.coreSegmentName = properties().coreSegmentName;
54 mid.providerSegmentName = providerSegmentName;
55 mid.entityName =
"images";
57 auto res = this->memoryReader().getLatestSnapshotIn(mid);
64 auto data = i.
dataAs<visionx::armem_images::arondto::ImageRGB>();
70 std::vector<CByteImage*>
73 std::vector<cv::Mat> mats;
74 getLatestRGBImages(providerSegmentName, mats);
76 std::vector<CByteImage*>
ret;
77 ret.reserve(mats.size());
79 for (
const auto& m : mats)
85 if (m.elemSize() == 1)
87 i =
new CByteImage(m.cols, m.rows, CByteImage::ImageType::eGrayScale);
89 else if (m.elemSize() == 3)
91 i =
new CByteImage(m.cols, m.rows, CByteImage::ImageType::eRGB24);
95 throw armarx::LocalException(
"Only grayscale and RGB images are allow for "
96 "conversion from cv::mat to cbyteimage.");
102 std::memcpy(i->pixels, m.data, i->width * i->height * i->bytesPerPixel);
113 return "depthReader.";
130 mid.memoryName = properties().memoryName;
131 mid.coreSegmentName = properties().coreSegmentName;
132 mid.providerSegmentName = providerSegmentName;
133 mid.entityName =
"images";
135 auto res = this->memoryReader().getLatestSnapshotIn(mid);
137 std::vector<cv::Mat>
ret;
140 res->forEachInstance(
143 auto data = i.
dataAs<visionx::armem_images::arondto::ImageDepth>();
150 std::optional<visionx::StereoCalibration>
153 std::optional<visionx::StereoCalibration> stereoCalibration = std::nullopt;
156 mid.memoryName =
"Vision";
157 mid.coreSegmentName =
"StereoCameraCalibration";
158 mid.providerSegmentName = providerSegmentName;
159 mid.entityName =
"CameraCalibration";
161 auto res = this->memoryReader().getLatestSnapshotIn(mid);
165 std::vector<visionx::arondto::StereoCameraCalibration> calibration;
166 res->forEachInstance(
169 auto data = i.
dataAs<visionx::arondto::StereoCameraCalibration>();
170 calibration.push_back(
data);
173 if (calibration.size() > 0)
176 visionx::arondto::StereoCameraCalibration dto = calibration[0];
182 return stereoCalibration;
221 return "cameraCalibrationReader.";
237 rgbReader.registerPropertyDefinitions(def);
238 depthReader.registerPropertyDefinitions(def);
239 cameraCalibrationReader.registerPropertyDefinitions(def);
245 rgbReader.connect(mns);
246 depthReader.connect(mns);
247 cameraCalibrationReader.connect(mns);
253 rgbReader.getLatestRGBImages(providerSegmentName,
ret);
256 std::vector<CByteImage*>
259 return rgbReader.getLatestRGBCByteImages(providerSegmentName);
265 return depthReader.getLatestDepthImages(providerSegmentName);
268 std::optional<visionx::StereoCalibration>
271 return cameraCalibrationReader.getStereoCameraCalibration(providerSegmentName);