日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

从一个点云里面创建一个深度图

發布時間:2025/3/15 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 从一个点云里面创建一个深度图 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這次,我們將顯示如何從一個點云和一個給定的傳感器來創造深度圖。下面的代碼,創建了一個在觀察者前面的矩形。

#include <pcl/range_image/range_image.h>int main (int argc, char** argv) {pcl::PointCloud<pcl::PointXYZ> pointCloud;// Generate the datafor (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;// We now want to create a range image from the above point cloud, with a 1deg angular resolutionfloat angularResolution = (float) ( 1.0f * (M_PI/180.0f)); // 1.0 degree in radiansfloat maxAngleWidth = (float) (360.0f * (M_PI/180.0f)); // 360.0 degree in radiansfloat maxAngleHeight = (float) (180.0f * (M_PI/180.0f)); // 180.0 degree in radiansEigen::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;pcl::RangeImage rangeImage;rangeImage.createFromPointCloud(pointCloud, angularResolution, maxAngleWidth, maxAngleHeight,sensorPose, coordinate_frame, noiseLevel, minRange, borderSize);std::cout << rangeImage << "\n"; }

下面是代碼解釋:

#include <pcl/range_image/range_image.h>int main (int argc, char** argv) {pcl::PointCloud<pcl::PointXYZ> pointCloud;// Generate the datafor (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.0 degree in radiansfloat maxAngleWidth = (float) (360.0f * (M_PI/180.0f)); // 360.0 degree in radiansfloat maxAngleHeight = (float) (180.0f * (M_PI/180.0f)); // 180.0 degree in radiansEigen::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;

上面那個部分定義了我們想去創建的深度圖的參數。

角度分辨率是1度,意味著光線將以一度來區別近鄰的像素點。maxAngleWidth=360和maxAngleHeight=190意味著我們模擬的深度圖傳感器有一個360度環繞的效果。你可以總是使用這些設置,因為深度圖將被裁剪成自動觀察的區域。你可以節省計算通過減少值。對于一個180度的激光雷達,后面的點將看不見,msxAngleWidth=180就夠了。

sensorPose定義了6DOF視覺傳感器的位置,以roll=pitch=yaw=0這個位置為原點的。

coordinate_frame=CAMERA_FRAME告訴我們x是朝右的,y是朝下的,z是朝前的。一個可選的參數是LASER_FRAME,x是朝前的,y是朝左的,z是朝下的。

對于noiseLevel=0來說,深度圖通過一個normal z-buffer來創建的。

如果minRange比0要大,那么靠得很近的點就會被忽略。

borderSize比0大的話,將會在裁剪的時候留下一邊框的未觀察到的點。

pcl::RangeImage rangeImage;rangeImage.createFromPointCloud(pointCloud, angularResolution, maxAngleWidth, maxAngleHeight,sensorPose, coordinate_frame, noiseLevel, minRange, borderSize);std::cout << rangeImage << "\n";

上面的這個代碼從點云里面創建了深度圖。

深度圖是繼承PointCloud這個類,這個點有x,y,z和深度。這里有3種點。有效的點的深度都是大于0的,無法觀察到的點如x=y=z=NAN和深度=-INFINITY。很遠的點x=y=z=NAN深度=INFINITY

運行結果

range image of size 42x36 with angular resolution 1deg/pixel and 1512 points

?

?

?

?

?

?

總結

以上是生活随笔為你收集整理的从一个点云里面创建一个深度图的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。