29 #include <Image/ImageProcessor.h>
43 offeringTopic(getProperty<std::string>(
"DebugObserverName").getValue());
44 offeringTopic(getProperty<std::string>(
"DebugDrawerTopicName").getValue());
46 doRewind = getProperty<bool>(
"Rewind").getValue();
48 Eigen::Vector2i dimensions = getProperty<Eigen::Vector2i>(
"Dimensions").getValue();
49 setImageFormat(visionx::ImageDimension(dimensions(0), dimensions(1)), visionx::eRgb);
52 rgbImages =
new CByteImage*[2];
53 rgbImages[0] =
new CByteImage(dimensions(0), dimensions(1), CByteImage::eRGB24);
54 rgbImages[1] =
new CByteImage(dimensions(0), dimensions(1), CByteImage::eRGB24);
55 depthBuffer = cv::Mat(dimensions(1), dimensions(0), CV_16UC1, 0.0);
57 std::string fileName = getProperty<std::string>(
"FileName").getValue();
61 ARMARX_ERROR <<
"Could not find point cloud file in ArmarXDataPath: " << fileName;
65 if (!std::filesystem::exists(fileName.c_str()))
71 fp = fopen(fileName.c_str(),
"rb");
75 if (fread(&totalFrames,
sizeof(int32_t), 1, fp) !=
sizeof(int32_t))
81 ARMARX_INFO <<
"total number of frames " << totalFrames;
88 debugObserver = getTopic<DebugObserverInterfacePrx>(getProperty<std::string>(
"DebugObserverName").getValue());
89 debugDrawer = getTopic<DebugDrawerInterfacePrx>(getProperty<std::string>(
"DebugDrawerTopicName").getValue());
108 if (currentFrame > totalFrames)
115 [[maybe_unused]]
auto r = fread(&totalFrames,
sizeof(int32_t), 1, fp);
125 ::ImageProcessor::Zero(rgbImages[0]);
126 ::ImageProcessor::Zero(rgbImages[1]);
132 [[maybe_unused]]
auto r = fread(×tamp,
sizeof(int64_t), 1, fp);
133 r = fread(&depthSize,
sizeof(int32_t), 1, fp);
134 r = fread(&imageSize,
sizeof(int32_t), 1, fp);
136 if (depthSize == rgbImages[1]->height * rgbImages[1]->width * 2)
138 r = fread(depthBuffer.data, depthSize, 1, fp);
141 else if (depthSize > 0)
143 uint8_t* tmpImage =
new uint8_t[depthSize];
145 unsigned long decompLength = rgbImages[1]->height * rgbImages[1]->width * 2;
147 r = fread(tmpImage, depthSize, 1, fp);
148 uncompress(depthBuffer.data, &decompLength, tmpImage, depthSize);
151 if (imageSize == rgbImages[0]->height * rgbImages[0]->width * 3)
153 r = fread(rgbImages[0]->pixels, imageSize, 1, fp);
155 else if (imageSize > 0)
157 std::vector<uint8_t> tmpImage(imageSize, 0);
159 r = fread(&tmpImage[0], imageSize, 1, fp);
160 cv::Mat decImg = cv::imdecode(tmpImage, 1);
161 imageSize = decImg.step * decImg.rows;
162 memcpy(rgbImages[0]->pixels, decImg.data, decImg.step * decImg.rows);
167 for (
int i = 0; i < rgbImages[1]->height; i++)
169 for (
int j = 0; j < rgbImages[1]->width; j++)
171 unsigned short value = depthBuffer.at<
unsigned short>(i, j);
173 rgbImages[1]->pixels[3 * (i * rgbImages[1]->width + j) + 0] =
value & 0xFF;
174 rgbImages[1]->pixels[3 * (i * rgbImages[1]->width + j) + 1] = (
value >> 8) & 0xFF;
182 for (
size_t i = 0; i < 2; i++)
184 memcpy(ppImageBuffers[i], rgbImages[i]->pixels, imageSize);
196 for (
size_t i = 0; i < 2; i++)