ground_region.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // Created by zx on 2021/5/20.
  3. //
  4. #ifndef LIDARMEASURE__GROUD_REGION_HPP_
  5. #define LIDARMEASURE__GROUD_REGION_HPP_
  6. #include "error_code/error_code.h"
  7. #include <opencv2/opencv.hpp>
  8. #include "match3d/detect_wheel_ceres3d.h"
  9. #include "configure.pb.h"
  10. #include "vlp16.hpp"
  11. #include <glog/logging.h>
  12. #include <google/protobuf/io/zero_copy_stream_impl.h>
  13. #include <google/protobuf/text_format.h>
  14. #include <google/protobuf/message.h>
  15. #include "tool/thread_condition.h"
  16. using google::protobuf::Message;
  17. using google::protobuf::io::CodedInputStream;
  18. using google::protobuf::io::CodedOutputStream;
  19. using google::protobuf::io::FileInputStream;
  20. using google::protobuf::io::FileOutputStream;
  21. using google::protobuf::io::ZeroCopyInputStream;
  22. using google::protobuf::io::ZeroCopyOutputStream;
  23. #include <pcl/point_types.h>
  24. #include <pcl/point_cloud.h>
  25. #include "message/ground_measure_msg.pb.h"
  26. class Ground_region
  27. {
  28. public:
  29. Ground_region();
  30. ~Ground_region();
  31. Error_manager init(std::string configure_file);
  32. Error_manager init(ground_region::Configure configure);
  33. Error_manager detect(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,const ground_region::Box& box,
  34. detect_wheel_ceres3d::Detect_result& result);
  35. private:
  36. bool read_proto_param(std::string file, ::google::protobuf::Message& parameter);
  37. Error_manager sync_capture(std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr>& cloud,double timeout_second=1.0);
  38. pcl::PointCloud<pcl::PointXYZ>::Ptr scans2cloud(const velodyne::Frame& frame,const ground_region::Calib_parameter& calib);
  39. //预处理点云, 并并判断雷达状态
  40. Error_manager prehandle_cloud(std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr>& clouds,
  41. message::Ground_measure_statu_msg& msg);
  42. bool classify_ceres_detect(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,double thresh_z,
  43. detect_wheel_ceres3d::Detect_result& result);
  44. static void thread_measure_func(Ground_region* p);
  45. std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> segmentation(pcl::PointCloud<pcl::PointXYZ>::Ptr sor_cloud);
  46. double distance(cv::Point2f p1, cv::Point2f p2);
  47. bool isRect(std::vector<cv::Point2f>& points);
  48. private:
  49. std::vector<velodyne::VLP16Capture*> m_lidars;
  50. public:
  51. ground_region::Configure m_configure;
  52. detect_wheel_ceres3d* m_detector;
  53. private:
  54. std::thread* m_running_thread;
  55. Thread_condition m_exit_condition;
  56. };
  57. #endif //LIDARMEASURE__GROUD_REGION_HPP_