18 std::string
imageEncoding(
bool isFloat,
int channels,
int bytesPerElement)
43 switch (bytesPerElement)
54 switch (bytesPerElement)
65 switch (bytesPerElement)
76 switch (bytesPerElement)
89 ENSENSO_ERROR(
"Invalid image encoding in binary NxLib node.");
95 auto image = ensenso::std::make_shared<Image>();
98 int width, height, channels, bytesPerElement;
99 double nxLibTimestamp;
100 node.getBinaryDataInfo(&width, &height, &channels, &bytesPerElement, &isFloat, &nxLibTimestamp);
105 image->header.frame_id = frame;
106 image->width = width;
107 image->height = height;
108 image->step = width * channels * bytesPerElement;
109 image->encoding =
imageEncoding(isFloat, channels, bytesPerElement);
111 node.getBinaryData(image->data, 0);
130 rightImage =
nullptr;
133 return { leftImage, rightImage };
138 std::vector<ImagePtrPair> result;
142 for (
int i = 0; i < node.count(); i++)
155 std::vector<ImagePtr>
imagesFromNxLibNode(NxLibItem
const& node, std::string
const& frame,
bool isFileCamera)
157 std::vector<ImagePtr> result;
161 for (
int i = 0; i < node.count(); i++)
176 double nxLibTimestamp;
177 node.getBinaryDataInfo(0, 0, 0, 0, 0, &nxLibTimestamp);
184 double nxLibTimestamp;
186 node.getBinaryData(pointMap, &nxLibTimestamp);
189 cv::extractChannel(pointMap, depthImage, 2);
192 depthImage /= 1000.0;
199 out_msg.
header.frame_id = frame;
201 out_msg.
image = depthImage;
208 std::vector<double> distParams(5, 0.);
210 auto getNxLibValue = [](NxLibItem
const& itemToCheck) ->
double {
214 value = itemToCheck.asDouble();
218 ENSENSO_WARN(
"The distortion parameter %s does not exist. Using value 0.0 instead.", itemToCheck.path.c_str());
223 if (distortionItem.isObject())
225 distParams[0] = getNxLibValue(distortionItem[itmK1]);
226 distParams[1] = getNxLibValue(distortionItem[itmK2]);
227 distParams[2] = getNxLibValue(distortionItem[itmT1]);
228 distParams[3] = getNxLibValue(distortionItem[itmT2]);
229 distParams[4] = getNxLibValue(distortionItem[itmK3]);
231 else if (distortionItem.isArray())
233 for (
int i = 0; i < 5; i++)
235 distParams[i] = getNxLibValue(distortionItem[i]);