当前位置: 首页 > news >正文

KITTI数据集(.bin数据)转换为点云数据(.pcd文件)

目录

cmake代码

代码


cmake代码

cmake_minimum_required(VERSION 3.17)
project(TEST2)set(CMAKE_CXX_STANDARD 14)# Find PCL
find_package(PCL 1.8 REQUIRED)# If PCL was found, add its include directories to the project
if(PCL_FOUND)include_directories(${PCL_INCLUDE_DIRS})link_directories(${PCL_LIBRARY_DIRS})add_definitions(${PCL_DEFINITIONS})
else()message(FATAL_ERROR "PCL not found.")
endif()add_executable(TEST2 main.cpp)# Link PCL libraries to the project
target_link_libraries(TEST2 ${PCL_LIBRARIES})

代码

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <fstream>
#include <iostream>
#include <vector>int main() {// Define file pathsstd::string input_filename = "/home/fairlee/KITTI/2011_09_26_drive_0011_sync/velodyne_points/data/0000000000.bin";std::string output_filename = "/home/fairlee/KITTI/2011_09_26_drive_0011_sync/velodyne_points/data/0000000000.pcd";// Open the binary filestd::ifstream input_file(input_filename, std::ios::binary);if (!input_file.good()) {std::cerr << "Error: Could not read file: " << input_filename << std::endl;return -1;}// Define point cloud objectpcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud(new pcl::PointCloud<pcl::PointXYZI>);// Read points from bin fileint i = 0;while (input_file.good() && !input_file.eof()) {pcl::PointXYZI point;input_file.read(reinterpret_cast<char*>(&point.x), sizeof(float));input_file.read(reinterpret_cast<char*>(&point.y), sizeof(float));input_file.read(reinterpret_cast<char*>(&point.z), sizeof(float));input_file.read(reinterpret_cast<char*>(&point.intensity), sizeof(float));point_cloud->points.push_back(point);i++;}input_file.close();// Set additional point cloud propertiespoint_cloud->width = i;point_cloud->height = 1;  // 1 for unorganized point cloudpoint_cloud->is_dense = true;// Save the point cloud to a PCD filepcl::io::savePCDFileASCII(output_filename, *point_cloud);std::cerr << "Saved " << point_cloud->points.size() << " data points to " << output_filename << std::endl;return 0;
}

http://www.lryc.cn/news/226426.html

相关文章:

  • 【电路笔记】-节点电压分析和网状电流分析
  • jenkins通知
  • 技术分享 | Spring Boot 异常处理
  • 【Python 千题 —— 基础篇】成绩评级
  • 【ARM Coresight OpenOCD 系列 2 -- OpenOCD 脚本语法详细介绍】
  • pytorch 初始化
  • process.env.XXX环境变量不生效的解决方法
  • QT项目|时间服务器架构
  • Java学习 10.Java-数组习题
  • Vue3使用vue-print-nb插件打印功能
  • Leetcode300 最长递增子序列
  • 2000-2022年上市公司数字化转型同群效应数据
  • Python 如何实践 Builder(生成器) 对象创建型设计模式?
  • 【Qt绘制小猪】以建造者模式绘制小猪
  • 开发中常用的SQL语句
  • Unreal UnLua + Lua Protobuf
  • java 类和对象 (图文搭配,万字详解!!)
  • pytorch DistributedDataParallel 分布式训练踩坑记录
  • Stable Diffusion webui 源码调试(三)
  • 工作学习记录
  • 邻接矩阵储存图实现深度优先遍历(C++)
  • hdlbits系列verilog解答(100位加法器)-42
  • 学者观察 | 数字经济中长期发展中的区块链影响力——清华大学柴跃廷
  • python-flask笔记
  • tensor和ndarray的相互转换,同时需要注意cuda和cpu的迁移
  • 《Swin Transformer: Hierarchical Vision Transformer using Shifted Windows》阅读笔记
  • Flink 基础 -- 应用开发(Table API SQL) 概念和通用API
  • Flink之Java Table API的使用
  • 【Unity细节】Unity中如何让组件失活而不是物体失活
  • [设计模式] 建造者模式