20#include "pcl/filters/voxel_grid.h"
21#include "pcl/io/pcd_io.h"
22#include "pcl/point_types.h"
43 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
51 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
56 pcl::PointCloud<PCLPointXYZIT> org_cloud;
57 if (pcl::io::loadPCDFile(file_path, org_cloud) < 0) {
58 AERROR <<
"Failed to load pcd file " << file_path;
61 cloud_out->
resize(org_cloud.size());
62 for (
size_t i = 0; i < org_cloud.size(); ++i) {
63 auto& pt = org_cloud.points[i];
64 auto& new_pt = cloud_out->
at(i);
68 new_pt.intensity = pt.intensity;
77 pcl::PointCloud<PCLPointXYZIT> pcl_cloud;
78 for (
size_t i = 0; i < cloud.
size(); ++i) {
79 if (cloud.
points_label().at(i) !=
static_cast<uint8_t
>(label))
87 pcl_cloud.push_back(point);
90 pcl::PCDWriter writer;
91 writer.writeBinaryCompressed(file_path, pcl_cloud);
92 }
catch (
const pcl::IOException& ex) {
93 AERROR << ex.detailedMessage();
99template <
typename Po
intT>
102 const pcl::PointCloud<pcl::PointXYZI>::Ptr& out_cloud_ptr) {
103 for (
size_t i = 0; i < org_cloud.
size(); ++i) {
104 PointT pt = org_cloud.
at(i);
105 pcl::PointXYZI point;
106 point.x =
static_cast<float>(pt.x);
107 point.y =
static_cast<float>(pt.y);
108 point.z =
static_cast<float>(pt.z);
109 point.intensity =
static_cast<float>(pt.intensity);
110 out_cloud_ptr->push_back(point);
115 const pcl::PointCloud<pcl::PointXYZI>::Ptr& org_cloud_ptr,
117 for (
size_t i = 0; i < org_cloud_ptr->size(); ++i) {
118 const auto& pt = org_cloud_ptr->at(i);
124 out_cloud_ptr->push_back(point);
129 const pcl::PointCloud<pcl::PointXYZI>::Ptr& cloud_ptr,
130 const pcl::PointCloud<pcl::PointXYZI>::Ptr& filtered_cloud_ptr,
131 float lx = 0.01f,
float ly = 0.01f,
float lz = 0.01f) {
132 pcl::VoxelGrid<pcl::PointXYZI> voxel_grid;
133 voxel_grid.setInputCloud(cloud_ptr);
134 voxel_grid.setLeafSize(lx, ly, lz);
135 voxel_grid.filter(*filtered_cloud_ptr);
143 (
float, x, x)(
float, y, y)(
float, z, z)(
144 std::uint8_t, intensity,
145 intensity)(
double, timestamp, timestamp))
148 (
float, x, x)(
float, y, y)(
float, z,
const std::vector< double > & points_timestamp() const
void resize(const size_t size) override
const std::vector< uint8_t > & points_label() const
std::vector< double > * mutable_points_timestamp()
const PointT * at(size_t col, size_t row) const
std::shared_ptr< PointFCloud > PointFCloudPtr
struct apollo::perception::lidar::PCLPointXYZIT EIGEN_ALIGN16
pcl::PointCloud< CPoint >::ConstPtr CPointCloudConstPtr
pcl::PointCloud< CPoint > CPointCloud
void TransformToPCLXYZI(const base::AttributePointCloud< PointT > &org_cloud, const pcl::PointCloud< pcl::PointXYZI >::Ptr &out_cloud_ptr)
bool WritePcdByLabel(const std::string &file_path, const base::PointFCloud &cloud, const LidarPointLabel &label)
void DownSampleCloudByVoxelGrid(const pcl::PointCloud< pcl::PointXYZI >::Ptr &cloud_ptr, const pcl::PointCloud< pcl::PointXYZI >::Ptr &filtered_cloud_ptr, float lx=0.01f, float ly=0.01f, float lz=0.01f)
bool LoadPCLPCD(const std::string &file_path, base::PointFCloud *cloud_out)
void TransformFromPCLXYZI(const pcl::PointCloud< pcl::PointXYZI >::Ptr &org_cloud_ptr, const base::PointFCloudPtr &out_cloud_ptr)
pcl::PointCloud< CPoint >::Ptr CPointCloudPtr