从一个(随机)点云创建一个深度图像
从点云和给定的传感器位置来创建深度图像。首先是生成一个矩形点云,然后基于该点云创建深度图像。
代码实现:
#include <pcl/range_image/range_image.h>//深度图像头文件
int main (int argc, char** argv) {
pcl::PointCloud<pcl::PointXYZ> pointCloud;//定义点云对象
//生成数据
for (float y=-0.5f; y<=0.5f; y+=0.01f) {
for (float z=-0.5f; z<=0.5f; z+=0.01f) {
pcl::PointXYZ point;
point.x = 2.0f - y;
point.y = y;
point.z = z;
pointCloud.points.push_back(point);//循环添加点云数据到点云对象
}
}
pointCloud.width = (uint32_t) pointCloud.points.size();
pointCloud.height = 1;//设置点云对象的头信息
//以1度为角分辨率,从上面创建的点云创建深度图像。
float angularResolution = (float) ( 1.0f * (M_PI/180.0f));
// 1度转弧度
float maxAngleWidth = (float) (360.0f * (M_PI/180.0f));
// 360.0度转弧度
float maxAngleHeight = (float) (180.0f * (M_PI/180.0f));
// 180.0度转弧度
Eigen::Affine3f s