pcl-helper.hpp 1.1 KB

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include <librealsense2/rs.hpp>
  3. #include <tuple>
  4. #include <filesystem>
  5. #include <pcl/io/ply_io.h>
  6. #include <pcl/point_types.h>
  7. #include <pcl/registration/icp.h>
  8. #include <pcl/filters/crop_box.h>
  9. typedef pcl::PointXYZRGB PointRGB;
  10. typedef pcl::PointCloud<PointRGB> PointCloudRGB;
  11. typedef PointCloudRGB::Ptr PtrCloud;
  12. class PCLHelper
  13. {
  14. public:
  15. using PointRGB = pcl::PointXYZRGB;
  16. using PointCloudRGB = pcl::PointCloud<PointRGB>;
  17. using PtrCloud = PointCloudRGB::Ptr;
  18. static PtrCloud points_to_pcl(const rs2::points &points, const rs2::video_frame &color);
  19. static void convert_and_save_ply(const std::string &fileName, const rs2::points &points, const rs2::video_frame &color);
  20. static void save_to_ply(const std::string folderPath, const std::string &fileName, const PtrCloud &cloud);
  21. static int icp(PtrCloud &cloud_target, PtrCloud &cloud_source, int iterations = 1);
  22. static PtrCloud crop_cloud(PtrCloud &cloud, float min_x, float min_y, float min_z, float max_x, float max_y, float max_z);
  23. private:
  24. static std::tuple<uint8_t, uint8_t, uint8_t> get_texcolor(rs2::video_frame texture, rs2::texture_coordinate texcoords);
  25. };