#ifndef MYPCL_H_ #define MYPCL_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace ai_matrix { class MyPcl final { public: static MyPcl *getins(); //点云压缩 void compressPCD(const pcl::PointCloud &cloud, std::stringstream &compressedData); //拟合车厢边缘线 void insert_plane_line(pcl::PointCloud &line, float x_min, float x_max, float y, float z, unsigned char r, unsigned char g, unsigned char b, float step = 0.02); //拟合装载区域边缘线 void insert_load_line(pcl::PointCloud &line, float x_min, float x_max, float y_min, float y_max, float z, unsigned char r, unsigned char g, unsigned char b, float step = 0.02); //拟合限制线 void insert_bound_line(pcl::PointCloud &line, float y_min, float y_max, float z_min, float z_max, float x, unsigned char r, unsigned char g, unsigned char b, float step = 0.02); //拟合识别物体边缘框 void insert_object_line(pcl::PointCloud &line, float x_min, float x_max, float y, float z_min, float z_max, unsigned char r, unsigned char g, unsigned char b, float step = 0.02); //坐标变换1,有参照物时用 void coords_convert(const pcl::PointCloud &cloud_in, pcl::PointCloud &cloud_out, const Eigen::Matrix4f &tf, float thetaz = 0); //坐标变换2,无参照物时用 void coords_convert(const pcl::PointCloud &cloud_in, pcl::PointCloud &cloud_out, float thetax = 0, float thetay = 0, float thetaz = 0, float radarz = 0, bool reverse = false); //取中心立方体 void cube_cloud(const pcl::PointCloud &cloud_in, std::vector &indices, const Eigen::Vector3f &min, const Eigen::Vector3f &max); //取中心立方体 void cube_cloud(const pcl::PointCloud &cloud_in, pcl::PointCloud &cloud_out, const Eigen::Vector3f &min, const Eigen::Vector3f &max); //取中心立方体 void cube_cloud(const pcl::PointCloud &cloud_in, pcl::PointCloud &cloud_out, std::vector &indices, const Eigen::Vector3f &min, const Eigen::Vector3f &max); private: MyPcl() = default; MyPcl(const MyPcl &) = delete; MyPcl(MyPcl &&) = delete; MyPcl &operator=(const MyPcl &) = delete; MyPcl &operator=(MyPcl &&) = delete; ~MyPcl() = default; //定义一个嵌套类,负责释放内存,操作系统自动完成,不用担心内存泄露 class GarbageCollector { public: ~GarbageCollector() { if (MyPcl::ins) { delete MyPcl::ins; MyPcl::ins = nullptr; } } }; static GarbageCollector gc; static MyPcl *ins; static std::mutex mx; //锁,保证线程安全 }; } #endif