03-点云⽂件常⽤格式转换(pcd,txt,ply,obj,stl)1. pcd转txt
1 #include <iostream>
2 #include <fstream>
3 #include <pcl/io/pcd_io.h>
4
5int main(int argc, char *argv[])
6 {
7
8 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
9 pcl::io::loadPCDFile("rabbit.pcd", *cloud);
10
11 std::ofstream outfile;
12 outfile.open("");肉皮冻怎么做
13
14for (size_t i = 0; i < cloud->points.size(); i++)
15 {
16 outfile << cloud->points[i].x << "\t" << cloud->points[i].y << "\t" << cloud->points[i].z << "\n";
17 }
18
19 system("pau");
20
21return0;
22 }
View Code
2. txt转pcd
1 #include <iostream>
2 #include <fstream>
3 #include <pcl\io\pcd_io.h>
4
5int main()
6 {
7 std::ifstream infile;
8 infile.open("");
9
10float x, y, z;
11 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
12
全国水土保持区划
13while (infile >> x >> y >> z)
14 {
15 cloud->push_back(pcl::PointXYZ(x, y, z));
16 }
17
蜻蜓眼读后感
18// 保存为⼆进制格式
19//pcl::io::savePCDFileBinary("rabbit_new.pcd", *cloud);
20
21// 保存为ASCII格式
22 pcl::io::savePCDFileASCII("rabbit_new.pcd", *cloud);
23
24 system("pau");
25
26return0;
27 }
View Code
3. pcd转ply
1 #include <iostream>
2 #include <pcl\io\pcd_io.h>
3 #include <pcl\io\ply_io.h>
4 #include <pcl\point_types.h>
5
6int main()
7 {
8
9 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
10 pcl::io::loadPCDFile("rabbit.pcd", *cloud);
激情5月11
12 pcl::io::savePLYFile("rabbit.ply", *cloud);
13
14 system("pau");
15
16return0;
17 }
View Code
4.ply 转pcd
马自达轿车1 #include <iostream>
2 #include <pcl\io\pcd_io.h>
最美夫妻3 #include <pcl\io\ply_io.h>
4 #include <pcl\point_types.h>
5
6int main()
7 {
8
9 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); 10
11 pcl::io::loadPLYFile("rabbit.ply", *cloud);
社会信息化
12
13
14 pcl::io::savePCDFileBinary("rabbit.pcd", *cloud);
15
16 system("pau");
亲切的反义词17
18return0;
19 }
View Code
5. obj/ply转pcd
obj/ply转pcd(均匀采样)