car_pose_detector.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * @Description: 底盘z高度检测类,准确识别出平移,旋转,车宽,底盘高度,供3D车轮算法优化出车辆准确信息
  3. * @Author: yct
  4. * @Date: 2021-09-16 15:02:49
  5. * @LastEditTime: 2021-11-16 15:45:02
  6. * @LastEditors: yct
  7. */
  8. #ifndef Z_DETECTOR_HH
  9. #define Z_DETECTOR_HH
  10. #include <iostream>
  11. #include <chrono>
  12. #include <ceres/ceres.h>
  13. #include <pcl/common/common.h>
  14. #include <pcl/point_cloud.h>
  15. #include <pcl/point_types.h>
  16. #include <pcl/filters/passthrough.h>
  17. #include <pcl/filters/statistical_outlier_removal.h>
  18. #include <opencv2/opencv.hpp>
  19. #include "tool/singleton.h"
  20. class Car_pose_detector : public Singleton<Car_pose_detector> {
  21. friend class Singleton<Car_pose_detector>;
  22. public:
  23. Car_pose_detector(const Car_pose_detector &) = delete;
  24. Car_pose_detector &operator=(const Car_pose_detector &) = delete;
  25. ~Car_pose_detector() = default;
  26. // 变换点云
  27. void inv_trans_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_ptr, double x, double y, double theta);
  28. // 变换点云
  29. void trans_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_ptr, double x, double y, double theta);
  30. // 创建两轴具体曲线
  31. void create_curve_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_ptr, double width);
  32. // 检测底盘z方向值,去中心,
  33. bool detect_pose(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr out_cloud_ptr,
  34. double &x, double &y, double &theta, double &width, double &z_value, bool debug_cloud = false);
  35. // 检测底盘z方向值,去中心,使用mat加速
  36. bool
  37. detect_pose_mat(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr out_cloud_ptr,
  38. double &x, double &y, double &theta, bool debug_cloud = false);
  39. // 生成优化图像,降低优化耗时
  40. static cv::Mat
  41. create_mat(double min_x, double max_x, double min_y, double max_y, double resolution_x, double resolution_y);
  42. private:
  43. // 父类的构造函数必须保护,子类的构造函数必须私有。
  44. Car_pose_detector() = default;
  45. static cv::Mat m_model;
  46. };
  47. #endif // !Z_DETECTOR_HH