当前位置:网站首页>使用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
边栏推荐
- ATT&CK 威胁情报
- Day3 classification management of Ruiji takeout project
- MySQL installation and configuration (super detailed, simple and practical)
- Excel-VBA 快速上手(十三、日期的常见用法)
- SSH password free login
- Paddlenlp text classification based on ernir3.0: take wos dataset as an example (hierarchical classification)
- Image is referred in multiple repositories
- The blueprint of flask complements openpyxl
- Hcip experiment (14)
- PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)
猜你喜欢

Sword finger offer II 052. flatten binary search tree (simple binary search tree DFS)

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

Soft exam network engineer

Ruiji takeout - background login function development

Hcip experiment (14)

HCIP(14)

Att & CK Threat Intelligence

Changes in the history of oscilloscope development
![[Ruiji takeout project] Day5 - Chapter 6 mobile verification code login](/img/53/c578e0d1428ea569fb412a20019924.png)
[Ruiji takeout project] Day5 - Chapter 6 mobile verification code login

What is time complexity
随机推荐
Excel-VBA 快速上手(十三、日期的常见用法)
Win11 how to open software notification
MySQL installation and configuration (super detailed, simple and practical)
静态路由和缺省路由实验
Ruiji takeout project - development of business development function Day2
Ngrok intranet penetration
SQL injection less34 (post wide byte injection + Boolean blind injection)
HCIP(10)
Paddlenlp text classification based on ernir3.0: take wos dataset as an example (hierarchical classification)
Sword finger offer II 064. magic Dictionary (medium dictionary tree string design)
LVS+KeepAlived高可用部署实战应用
Establishment of Ruiji takeout development environment
[leetcode] maximum depth of binary tree
Lotus 1.16.0 extend sector expiration time
Paddlenlp is based on ernir3.0 text classification. Take the traditional Chinese medicine search and retrieval semantic map classification (kuake-qic) as an example [multi classification (single label
PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
近期bug总结
Sword finger offer II 053. Medium order successor in binary search tree (medium binary search tree DFS)
Hcip experiment (15)
使用webWorker执行后台任务