1.使用cv_bridge
#include <cv_bridge/cv_bridge.h>
void CB(const sensor_msgs::ImageConstPtr& depth) {
cv_bridge::CvImageConstPtr depth_ptr;
depth_ptr =
cv_bridge::toCvShare(depth, sensor_msgs::image_encodings::TYPE_32FC1);
cv::imshow("res", depth_ptr->image);
cv::waitKey(1);
}
- 显示的图像不对,试了好几个image_encodings都不行
2.直接获取距离
- 属性
- height: 480
- width: 640
- encoding: “16UC1”
- is_bigendian: 0
typedef