当前位置:网站首页>使用PCL批量将点云.bin文件转.pcd
使用PCL批量将点云.bin文件转.pcd
2022-07-28 20:50:00 【啥都生】

B站|公众号:啥都会一点的研究生
- 新建文件夹datasets
- datasets文件将下新建两个文件夹
bin与pcd,bin中存放要转换的二进制文件,pcd存放转换后的点云文件 - datasets下新建CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(bin2pcd)
find_package(PCL 1.2 REQUIRED)
find_package(Boost COMPONENTS program_options REQUIRED )
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(bin2pcd bin2pcd.cpp)
target_link_libraries (bin2pcd ${PCL_LIBRARIES} ${Boost_LIBRARIES})
install(TARGETS bin2pcd RUNTIME DESTINATION bin)
- 新建bin2pcd.cpp
#include <boost/program_options.hpp>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/common/io.h>
#include <pcl/io/vtk_io.h>
#include <vector>
#include <iostream>
#include <fstream>
using namespace pcl;
using namespace std;
void topcd(string name);
void topcd(string infile,string outfile) {
// load point cloud
fstream input(infile.c_str(), ios::in | ios::binary);
if (!input.good()) {
cerr << "Could not read file: " << infile << endl;
exit(EXIT_FAILURE);
}
input.seekg(0, ios::beg);
pcl::PointCloud<PointXYZI>::Ptr points(new pcl::PointCloud<PointXYZI>);
int i;
for (i = 0; input.good() && !input.eof(); i++) {
PointXYZI point;
input.read((char*)&point.x, 3 * sizeof(float));
input.read((char*)&point.intensity, sizeof(float));
points->push_back(point);
}
input.close();
cout << "Read point cloud with " << i << " points, writing to " << outfile << endl;
pcl::PCDWriter writer;
// Save DoN features
writer.write<PointXYZI>(outfile, *points, false);
}
int main(int argc, char** argv) {
string binpath = "/home/xxxx/datasets/bin/";
string pcdpath = "/home/xxxx/datasets/pcd/";
vector<boost::filesystem::path> stream(boost::filesystem::directory_iterator{
binpath}, boost::filesystem::directory_iterator{
});
sort(stream.begin(), stream.end());
auto streamIterator = stream.begin();
int j = 0;
while(streamIterator != stream.end()){
string binfile((*streamIterator).string());
stringstream ss;
string str;
ss << setw(10) << setfill('0') << j; // 补零
ss >> str;
string surfix = ".pcd";
string pcdfile = pcdpath + str + surfix;
topcd(binfile,pcdfile);
streamIterator++;
j++;
}
return 0;
}
- 注意仅需修改
binpath与pcdpath为你的路径 - 新建build文件夹,所以现在的文件层级为这样
├── bin2pcd.cpp
├── build
├── CMakeLists.txt
└── datasets
├── bin
├── 0000000000.bin
├── 0000000001.bin
...
└── pcd
├── 0000000000.bin
├── 0000000001.bin
...
- 剩下的步骤就是正常编译,
进入build文件夹
cmake .. && make -j12
- 然后运行文件
./bin2pcd
边栏推荐
- If you want to grow rapidly, you must first experience a major blow!
- What does GPRS network mean
- Which is the file transfer command in the basic services of the Internet
- [CVPR 2021] cylinder3d: cylindrical asymmetric 3D convolution network for LIDAR point cloud segmentation
- SQL injection less38 (Stack Injection)
- 75. Color classification (medium array double pointer sorting)
- How do we do full link grayscale on the database?
- JMeter installs third-party plug-ins plugins Manager
- Paddlenlp is based on ernir3.0 text classification. Take the crime prediction task of cail2018-small dataset as an example [multiple tags]
- gprs网络指的是什么
猜你喜欢

Ruiji takeout project - development of business development function Day2

Which is the file transfer command in the basic services of the Internet

CMD common commands

Sword finger offer II 054. Sum of all values greater than or equal to nodes (medium binary search tree DFS)

105. Construct binary tree from preorder and inorder traversal sequence (medium binary tree DFS hash table binary tree)

SQL injection less42 (post stack injection)

【转载】token令牌在登录场景使用

79. Word search (medium string array matrix backtracking)
Integrating database Ecology: using eventbridge to build CDC applications

Win11 how to open software notification
随机推荐
Establishment of Ruiji takeout development environment
Wechat applet uses canvas drawing, round avatar, network background, text, dotted line, straight line
2021 mathematical modeling group B exercise
LeetCode刷题系列之-多数之和类型
Kali source solution software cannot be installed correctly
Sword finger offer II 067. maximum XOR (medium prefix tree bit operation array)
Leetcode integer exercises integer inversion
NPM switch Taobao source (NPM source)
76. Minimum coverage substring (hard sliding window hash table string)
Jmeter 安装第三方插件 Plugins Manager
静态成员static详解
PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)
MySQL installation and configuration (super detailed, simple and practical)
flask之蓝图 补充openpyxl
Overall introduction of Ruiji takeout project
微信小程序使用canvas绘图,圆形头像,网络背景图,文字,虚线,直线
Analysis notes on let (const) temporary dead zone in JS
SQL注入 Less38(堆叠注入)
Paddlenlp is based on ernir3.0 text classification. Take the crime prediction task of cail2018-small dataset as an example [multiple tags]
Alibaba cloud CDN practice