detect_wheel_ceres.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // Created by zx on 2020/7/1.
  3. //
  4. #ifndef CERES_TEST_DETECT_WHEEL_CERES_H
  5. #define CERES_TEST_DETECT_WHEEL_CERES_H
  6. #include <ceres/ceres.h>
  7. #include <glog/logging.h>
  8. #include <pcl/point_types.h>
  9. #include <pcl/point_cloud.h>
  10. #include <pcl/common/centroid.h>
  11. #include <opencv2/opencv.hpp>
  12. #include <iostream>
  13. #include <string>
  14. #include <chrono>
  15. #include "boost/format.hpp"
  16. class detect_wheel_ceres {
  17. public:
  18. struct Detect_result
  19. {
  20. public:
  21. double cx;
  22. double cy;
  23. double theta;
  24. double wheel_base;
  25. double width;
  26. double front_theta;
  27. bool success;
  28. Detect_result& operator=(const Detect_result detect_result)
  29. {
  30. this->cx = detect_result.cx;
  31. this->cy = detect_result.cy;
  32. this->theta = detect_result.theta;
  33. this->wheel_base = detect_result.wheel_base;
  34. this->width = detect_result.width;
  35. this->front_theta = detect_result.front_theta;
  36. this->success = detect_result.success;
  37. return *this;
  38. }
  39. };
  40. struct Loss_result
  41. {
  42. public:
  43. double lf_loss;
  44. double rf_loss;
  45. double lb_loss;
  46. double rb_loss;
  47. double total_avg_loss;
  48. Loss_result& operator=(const Loss_result& loss_result)
  49. {
  50. this->lf_loss = loss_result.lf_loss;
  51. this->rf_loss = loss_result.rf_loss;
  52. this->lb_loss = loss_result.lb_loss;
  53. this->rb_loss = loss_result.rb_loss;
  54. this->total_avg_loss = loss_result.total_avg_loss;
  55. return *this;
  56. }
  57. };
  58. detect_wheel_ceres();
  59. ~detect_wheel_ceres();
  60. bool detect(std::vector<pcl::PointCloud<pcl::PointXYZ>> cloud_vec, Detect_result &detect_result);
  61. protected:
  62. void transform_src(Detect_result detect_result);
  63. bool update_mat(int rows, int cols);
  64. bool Solve(Detect_result &detect_result, double &avg_loss);
  65. bool Solve(Detect_result &detect_result, Loss_result &loss_result, bool save_img=false);
  66. void debug_img(Detect_result detect_result, Loss_result loss_result, bool save_img=false, std::string out_img_path="");
  67. void create_mark(double x,double y,double theta,pcl::PointCloud<pcl::PointXYZ>& cloud);
  68. public:
  69. pcl::PointCloud<pcl::PointXYZ> m_left_front_cloud_out; //左前点云
  70. pcl::PointCloud<pcl::PointXYZ> m_right_front_cloud_out; //右前点云
  71. pcl::PointCloud<pcl::PointXYZ> m_left_rear_cloud_out; //左后点云
  72. pcl::PointCloud<pcl::PointXYZ> m_right_rear_cloud_out; //右后点云
  73. protected:
  74. pcl::PointCloud<pcl::PointXYZ> m_left_front_cloud; //左前点云
  75. pcl::PointCloud<pcl::PointXYZ> m_right_front_cloud; //右前点云
  76. pcl::PointCloud<pcl::PointXYZ> m_left_rear_cloud; //左后点云
  77. pcl::PointCloud<pcl::PointXYZ> m_right_rear_cloud; //右后点云
  78. cv::Mat m_map; //保存一份地图用作匹配
  79. };
  80. #endif //CERES_TEST_DETECT_WHEEL_CERES_H