locater.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // Created by zx on 2019/12/30.
  3. //
  4. #ifndef LOCATER_H
  5. #define LOCATER_H
  6. #include "locate_task.h"
  7. #include "locater_parameter.pb.h"
  8. #include "../error_code/error_code.h"
  9. #include "point_sift_segmentation.h"
  10. #include "YoloDetector.h"
  11. #include "cnn3d_segmentation.h"
  12. #include <mutex>
  13. class Locater
  14. {
  15. public:
  16. Locater();
  17. ~Locater();
  18. //初始化测量算法参数
  19. Error_manager init(Measure::LocateParameter parameter);
  20. //获取测量模块状态(错误码);返回是否能执行任务,以及不能执行任务的原因
  21. Error_manager get_error();
  22. //执行任务,
  23. //task:测量任务
  24. //time_out:超时时间,单位秒
  25. Error_manager execute_task(Task_Base* task,double time_out=5);
  26. protected:
  27. //测量算法函数
  28. //cloud_in:输入点云
  29. //locate_information:测量结果
  30. //work_dir:中间文件保存路径
  31. Error_manager locate(pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_in,
  32. Locate_information& locate_information, std::string work_dir);
  33. //yolo定位车辆外接矩形
  34. //cloud_in:输入点云,定位算法内部不会修改点云内容
  35. //boxes:定位到的外接box框
  36. //work_dir:中间文件输出路径
  37. Error_manager locate_yolo(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in,
  38. std::vector<YoloBox>& boxes, std::string work_dir);
  39. //根据yolo识别结果, 利用PointSift从场景中分割车辆点云
  40. //cloud:输入点云
  41. //boxes:yolo识别结果
  42. //cloud_target:车辆点云
  43. //work_dir:中间文件保存路径
  44. Error_manager locate_sift(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, std::vector<YoloBox> boxes,
  45. pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud_wheel,pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud_car,
  46. std::string work_dir);
  47. //输入汽车点云,识别轮胎,并计算轴长,宽,中心,旋转角
  48. Error_manager locate_wheel(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,float& center_x,float& center_y,
  49. float& wheel_base,float& width,float& angle,std::string work_dir);
  50. //根据汽车点云计算车高
  51. //cloud_car:车辆点云
  52. Error_manager measure_height(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_car,float& height);
  53. /*
  54. * 保存点云成txt到文件
  55. */
  56. static void save_cloud_txt(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,std::string save_file);
  57. private:
  58. Measure::LocateParameter m_locate_parameter;
  59. Point_sift_segmentation* mp_point_sift;
  60. YoloDetector* mp_yolo_detector;
  61. Cnn3d_segmentation* mp_cnn3d;
  62. std::mutex m_mutex_lock;
  63. };
  64. #endif //LOCATER_H