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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

点云提取扫描线

發(fā)布時(shí)間:2023/12/29 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 点云提取扫描线 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.掃描線提取原理

目前車(chē)載LiDAR系統(tǒng)搭載的激光掃描儀主要是線性掃描,獲得的掃描點(diǎn)在目標(biāo)上按掃描線排列。在同一掃描線中,系統(tǒng)記錄的連續(xù)激光腳點(diǎn)的掃描角度差值為固定值(一般為激光掃描儀的角度分辨率)。在一個(gè)完整的掃描周期中,若掃描視場(chǎng)角為頂部天空,會(huì)出現(xiàn)無(wú)激光腳點(diǎn)返回的情況。此時(shí)當(dāng)前掃描線的最后一個(gè)點(diǎn)和下一條掃描線的起始點(diǎn)的掃描角度有一個(gè)非規(guī)律的階躍。同理,因?yàn)檐?chē)載激光點(diǎn)云的連續(xù)性,當(dāng)掃描視角為頂部天空時(shí),GPS時(shí)間差也會(huì)出現(xiàn)一個(gè)非規(guī)律的階躍。因此可以設(shè)置一個(gè)角度閡值或時(shí)間閡值檢測(cè)掃描線兩端的斷點(diǎn),將連續(xù)點(diǎn)云歸于一條掃描線中,從而將離散的掃描點(diǎn)轉(zhuǎn)化成有序的二維掃描線數(shù)據(jù)集。(參考自方莉娜博士論文)
由于.las格式的點(diǎn)云文件包含每個(gè)離散點(diǎn)的掃描角度和GPS時(shí)間信息,所以可以按照上述方法提取出掃描線,并按照掃描線進(jìn)行點(diǎn)云特征識(shí)別與分析等。本文的例子采用時(shí)間閾值提取掃描線。

2.核心代碼實(shí)現(xiàn)

2.1 自定義pcl點(diǎn)云類(lèi)型
struct myPointXYZTI {PCL_ADD_POINT4D;union{float coordinate[3];struct{float x;float y;float z;};};double GPSTime;int intensity;EIGEN_MAKE_ALIGNED_OPERATOR_NEW; }EIGEN_ALIGN16;POINT_CLOUD_REGISTER_POINT_STRUCT(myPointXYZTI,// 注冊(cè)點(diǎn)類(lèi)型宏(float, x, x)(float, y, y)(float, z, z)(double, GPSTime, GPSTime)(int, intensity, intensity))
2.2 讀取點(diǎn)云txt文件

txt文件點(diǎn)云按行保存,格式為:X,Y,Z,GPSTime,intensity .

bool CloudIO::readTxtFile(const string &fileName, const char tag, const mypcXYZTIPtr &pointCloud) {cout << "reading file start..... " << endl;ifstream fin(fileName);string linestr;while (getline(fin, linestr)){vector<string> strvec;string s;stringstream ss(linestr);while (getline(ss, s, tag)){strvec.push_back(s);}myPointXYZTI p;p.x = stod(strvec[0]);p.y = stod(strvec[1]);p.z = stod(strvec[2]);p.GPSTime = stod(strvec[3]);p.intensity = stoi(strvec[4]);pointCloud->points.push_back(p);}fin.close();cout << "reading file finished! " << endl;cout << "There are " << pointCloud->points.size() << " points!" << endl;return true; }
2.3 掃描線提取
void CloudIO::extractScanLine(mypcXYZTIPtr cloud, vector<vector<int> >& ScanLineVec) {vector<int> temp;for (int i = 1; i < cloud->points.size() - 1; i++){double time = cloud->points[i].GPSTime - cloud->points[i - 1].GPSTime;if (fabs(time) < 0.0015){temp.push_back(i);}else{ScanLineVec.push_back(temp);vector<int>().swap(temp);}}//第一個(gè)點(diǎn)加入第一條掃描線ScanLineVec[0].push_back(0);cout << "ScanLineVec size: " << ScanLineVec.size() << endl; }
2.4 掃描線采樣顯示
void CloudIO::ScanLineDisplay(mypcXYZTIPtr &cloud, vector<vector<int> >& ScanLineVec, int ScanLineNum) {pcl::PointCloud<pcl::PointXYZRGB>::Ptr rgbcloud(new pcl::PointCloud<pcl::PointXYZRGB>);pcl::PointXYZRGB p;bool flag = true;for (int i = 0; i < ScanLineVec.size(); i++){if (i % ScanLineNum == 0){for (int j = 0; j < ScanLineVec[i].size(); j++){p.x = cloud->points[ScanLineVec[i].at(j)].x;p.y = cloud->points[ScanLineVec[i].at(j)].y;p.z = cloud->points[ScanLineVec[i].at(j)].z;if (flag == true){p.r = 225; p.g = 0; p.b = 0;}else{p.r = 0; p.g = 255; p.b = 0;}rgbcloud->points.push_back(p);}if (flag == true){flag = false;}else{ flag = true; }}}cout << rgbcloud->points.size() << endl;boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));viewer->setBackgroundColor(255, 255, 255);viewer->addPointCloud(rgbcloud, "Ground");while (!viewer->wasStopped()){viewer->spinOnce(100);boost::this_thread::sleep(boost::posix_time::microseconds(100000));} }
2.5 結(jié)果顯示


2.6 備注

1.上述點(diǎn)云掃描線采樣間隔為6,對(duì)相鄰掃描線賦不同顏色進(jìn)行區(qū)分。
2.時(shí)間間隔參數(shù)的設(shè)置主要依據(jù)激光掃描儀的掃描頻率或?qū)υ键c(diǎn)云時(shí)間直方圖進(jìn)行分析。

歡迎關(guān)注我的公眾號(hào)。

總結(jié)

以上是生活随笔為你收集整理的点云提取扫描线的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。