15 std::string
imageEncoding(
bool isFloat,
int channels,
int bytesPerElement)
40 switch (bytesPerElement)
51 switch (bytesPerElement)
62 switch (bytesPerElement)
73 switch (bytesPerElement)
86 ROS_ERROR(
"Invalid image encoding in binary NxLib node.");
92 auto image = boost::make_shared<sensor_msgs::Image>();
95 int width, height, channels, bytesPerElement;
97 node.getBinaryDataInfo(&width, &height, &channels, &bytesPerElement, &isFloat, ×tamp);
100 image->header.frame_id = frame;
101 image->width = width;
102 image->height = height;
103 image->step = width * channels * bytesPerElement;
104 image->encoding =
imageEncoding(isFloat, channels, bytesPerElement);
106 node.getBinaryData(image->data, 0);
112 std::string
const& frame)
117 return { leftImage, rightImage };
121 std::string
const& frame)
123 std::vector<std::pair<sensor_msgs::ImagePtr, sensor_msgs::ImagePtr>> result;
127 for (
int i = 0; i < node.count(); i++)
142 std::vector<sensor_msgs::ImagePtr> result;
146 for (
int i = 0; i < node.count(); i++)
162 node.getBinaryDataInfo(0, 0, 0, 0, 0, ×tamp);
171 node.getBinaryData(pointMap, ×tamp);
174 cv::extractChannel(pointMap, depthImage, 2);
177 depthImage /= 1000.0;
182 out_msg.
header.frame_id = frame;
184 out_msg.
image = depthImage;
191 std::vector<double> distParams(5, 0.);
195 info->D = distParams;
199 auto getNxLibValue = [](NxLibItem
const& itemToCheck) ->
double {
203 value = itemToCheck.asDouble();
207 ROS_WARN(
"The distortion parameter %s does not exist. Using value 0.0 instead.", itemToCheck.path.c_str());
212 if (distortionItem.isObject())
214 distParams[0] = getNxLibValue(distortionItem[itmK1]);
215 distParams[1] = getNxLibValue(distortionItem[itmK2]);
216 distParams[2] = getNxLibValue(distortionItem[itmT1]);
217 distParams[3] = getNxLibValue(distortionItem[itmT2]);
218 distParams[4] = getNxLibValue(distortionItem[itmK3]);
220 else if (distortionItem.isArray())
222 for (
int i = 0; i < 5; i++)
224 info->D.push_back(getNxLibValue(distortionItem[i]));
227 info->D = distParams;
const std::string TYPE_16UC4
sensor_msgs::ImagePtr imageFromNxLibNode(NxLibItem const &node, std::string const &frame)
const std::string TYPE_64FC3
const std::string TYPE_8UC4
ros::Time timestampFromNxLibNode(const NxLibItem &node)
std::vector< sensor_msgs::ImagePtr > imagesFromNxLibNode(NxLibItem const &node, std::string const &frame)
double const NXLIB_TIMESTAMP_OFFSET
const std::string TYPE_32FC4
sensor_msgs::ImagePtr depthImageFromNxLibNode(NxLibItem const &node, std::string const &frame)
std::string imageEncoding(bool isFloat, int channels, int bytesPerElement)
std::pair< sensor_msgs::ImagePtr, sensor_msgs::ImagePtr > imagePairFromNxLibNode(const NxLibItem &node, std::string const &frame)
void fillDistortionParamsFromNxLib(NxLibItem const &distortionItem, sensor_msgs::CameraInfoPtr const &info)
const std::string TYPE_32FC1
const std::string PLUMB_BOB
const std::string TYPE_8UC2
const std::string TYPE_64FC4
const std::string TYPE_16UC3
const std::string TYPE_16UC2
const std::string TYPE_32SC2
const std::string TYPE_64FC1
const std::string TYPE_64FC2
const std::string TYPE_32SC3
const std::string TYPE_8UC3
const std::string TYPE_32SC4
const std::string TYPE_32FC3
const std::string TYPE_32FC2
std::vector< std::pair< sensor_msgs::ImagePtr, sensor_msgs::ImagePtr > > imagePairsFromNxLibNode(const NxLibItem &node, std::string const &frame)
const std::string TYPE_32SC1
sensor_msgs::ImagePtr toImageMsg() const