如何从点云创建深度图像(1)
本小节一起学习如何从点云和给定的传感器位置来创建深度图像,下面的程序,首先是生成一个矩形点云,然后基于该点云创建深度图像。
代码
首先,在PCL(Point Cloud Learning)中国协助发行的书提供光盘的第9章例1文件夹中,打开名为range_image_creation.cpp的代码文件。 解释说明
下面来解析打开源代码中的关键语句。
#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; //设置点云对象的头信息
这段程序首先创建一组数据作为点云的数据内容,再设置文件头的信息,整个实现生成一个呈矩形形状的点云。
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 sensorPose = (Eigen::Affine3f)Eigen::Translation3f(0.0f, 0.0f, 0.0f); //采集位置
pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME; //深度图像遵循的坐标系统
float noiseLevel=0.00;
float minRange = 0.0f;
int borderSize = 1; 未完待续,敬请关注“如何从点云创建深度图像(2)”的其他内容。 |
|
来自: 昵称43128558 > 《工程》