detect_wheel_ceres3d.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // Created by zx on 2020/7/1.
  3. //
  4. #ifndef DETECT_WHEEL_CERES_3D_H
  5. #define DETECT_WHEEL_CERES_3D_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. #include "hybrid_grid.hpp"
  17. class detect_wheel_ceres3d {
  18. public:
  19. struct Loss_result
  20. {
  21. public:
  22. double lf_loss;
  23. double rf_loss;
  24. double lb_loss;
  25. double rb_loss;
  26. double total_avg_loss;
  27. Loss_result& operator=(const Loss_result& loss_result)
  28. {
  29. this->lf_loss = loss_result.lf_loss;
  30. this->rf_loss = loss_result.rf_loss;
  31. this->lb_loss = loss_result.lb_loss;
  32. this->rb_loss = loss_result.rb_loss;
  33. this->total_avg_loss = loss_result.total_avg_loss;
  34. return *this;
  35. }
  36. };
  37. struct Detect_result
  38. {
  39. public:
  40. double cx;
  41. double cy;
  42. double theta;
  43. double wheel_base;
  44. double width;
  45. double body_width;
  46. double front_theta;
  47. bool success;
  48. Loss_result loss;
  49. Detect_result& operator=(const Detect_result& detect_result)
  50. {
  51. this->cx = detect_result.cx;
  52. this->cy = detect_result.cy;
  53. this->theta = detect_result.theta;
  54. this->wheel_base = detect_result.wheel_base;
  55. this->width = detect_result.width;
  56. this->front_theta = detect_result.front_theta;
  57. this->success = detect_result.success;
  58. this->body_width=detect_result.body_width;
  59. this->loss=detect_result.loss;
  60. return *this;
  61. }
  62. };
  63. detect_wheel_ceres3d(pcl::PointCloud<pcl::PointXYZ>::Ptr left_grid_cloud,
  64. pcl::PointCloud<pcl::PointXYZ>::Ptr right_grid_cloud);
  65. ~detect_wheel_ceres3d();
  66. bool detect(std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> cloud_vec, Detect_result &detect_result, std::string &error_info);
  67. void save_debug_data(std::string file );
  68. protected:
  69. void save_model(std::string file);
  70. bool Solve(Detect_result &detect_result, Loss_result &loss_result, std::string &error_info);
  71. void get_costs(double* variable,double &lf, double &rf, double &lr, double &rr);
  72. public:
  73. pcl::PointCloud<pcl::PointXYZ> m_left_front_transformed_cloud; //左前点云
  74. pcl::PointCloud<pcl::PointXYZ> m_right_front_transformed_cloud; //右前点云
  75. pcl::PointCloud<pcl::PointXYZ> m_left_rear_transformed_cloud; //左后点云
  76. pcl::PointCloud<pcl::PointXYZ> m_right_rear_transformed_cloud; //右后点云
  77. pcl::PointCloud<pcl::PointXYZ> m_left_front_cloud; //左前点云
  78. pcl::PointCloud<pcl::PointXYZ> m_right_front_cloud; //右前点云
  79. pcl::PointCloud<pcl::PointXYZ> m_left_rear_cloud; //左后点云
  80. pcl::PointCloud<pcl::PointXYZ> m_right_rear_cloud; //右后点云
  81. private:
  82. HybridGrid* mp_left_grid;
  83. HybridGrid* mp_right_grid;
  84. };
  85. #endif //DETECT_WHEEL_CERES_3D_H