cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
formats.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cpp-toolbox/cpp-toolbox_export.hpp>
9
10namespace toolbox::io
11{
12template<typename T>
13CPP_TOOLBOX_EXPORT std::unique_ptr<toolbox::types::point_cloud_t<T>>
14read_point_cloud(const std::string& path)
15{
16 auto extension = toolbox::file::get_file_extension(path);
17 LOG_INFO_S << "Reading point cloud from " << path << " with extension "
18 << extension;
19 if (extension == ".pcd") {
20 return read_pcd<T>(path);
21 }
22
23 if (extension == ".bin") {
24 return read_kitti_bin<T>(path);
25 }
26
27 LOG_ERROR_S << "Unsupported file extension: " << extension;
28 return nullptr;
29}
30
31template<typename T>
32CPP_TOOLBOX_EXPORT bool write_point_cloud(
33 const std::string& path, const toolbox::types::point_cloud_t<T>& cloud)
34{
35 auto extension = toolbox::file::get_file_extension(path);
36 if (extension == "pcd") {
37 return write_pcd(path, cloud);
38 }
39
40 if (extension == "bin") {
41 return write_kitti_bin(path, cloud);
42 }
43
44 LOG_ERROR_S << "Unsupported file extension: " << extension;
45 return false;
46}
47} // namespace toolbox::io
包含点和相关数据的点云类 / A point cloud class containing points and associated data
Definition point.hpp:268
#define LOG_INFO_S
INFO级别流式日志的宏 / Macro for INFO level stream logging.
Definition thread_logger.hpp:1330
#define LOG_ERROR_S
ERROR级别流式日志的宏 / Macro for ERROR level stream logging.
Definition thread_logger.hpp:1332
CPP_TOOLBOX_EXPORT auto get_file_extension(const std::filesystem::path &path) -> std::string
获取路径的文件扩展名 / Get the file extension of a path
< 用于列出目录下的文件/For listing files in a directory
Definition dataloader.hpp:15
CPP_TOOLBOX_EXPORT std::unique_ptr< toolbox::types::point_cloud_t< T > > read_point_cloud(const std::string &path)
Definition formats.hpp:14
CPP_TOOLBOX_EXPORT bool write_point_cloud(const std::string &path, const toolbox::types::point_cloud_t< T > &cloud)
Definition formats.hpp:32
CPP_TOOLBOX_EXPORT bool write_kitti_bin(const std::string &path, const toolbox::types::point_cloud_t< T > &cloud)
将点云数据写入 KITTI 点云文件的独立函数。/Standalone function to write point cloud data to a KITTI point cloud file.
Definition kitti_impl.hpp:258
CPP_TOOLBOX_EXPORT bool write_pcd(const std::string &path, const toolbox::types::point_cloud_t< T > &cloud, bool binary)
将点云数据写入 PCD 文件的独立函数。/Standalone function to write point cloud data to a PCD file.
Definition pcd_impl.hpp:833