detect_manager.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include <thread>
  3. #include "error_code/error_code.hpp"
  4. #include "ceres_detect/detect_wheel_ceres.h"
  5. #include "proto/enum_type.pb.h"
  6. #include "proto/detect_message.pb.h"
  7. #include "thread/thread_condition.h"
  8. #include "vzense/device_tof3d.h"
  9. #ifdef ENABLE_TENSORRT_DETECT
  10. #include "detect/tensorrt_detect/wheel-detector.h"
  11. #else
  12. #include "detect/onnx_detect/wheel-detector.h"
  13. #endif
  14. #include "detect/ceres_detect/car_pose_detector.h"
  15. #include "detect/ceres_detect/wheel_detector.h"
  16. #include "detect/ceres_detect/detect_wheel_ceres.h"
  17. #include "communication/transitData.h"
  18. class DetectManager {
  19. public:
  20. struct DetectResult {
  21. WheelCeresDetector::WheelDetectResult wheel[DeviceAzimuth::DEVICE_AZIMUTH_MAX];
  22. Car_pose_detector::CarDetectResult car;
  23. void reset() {
  24. for (int i = 0; i < DeviceAzimuth::DEVICE_AZIMUTH_MAX; i++) {
  25. wheel[i].reset();
  26. }
  27. car.reset();
  28. }
  29. std::string info() {
  30. std::string str = car.info();
  31. for (int i = 0; i < DeviceAzimuth::DEVICE_AZIMUTH_MAX; i++) {
  32. str += wheel[i].info();
  33. }
  34. return str;
  35. }
  36. };
  37. public:
  38. static DetectManager *iter() {
  39. static DetectManager *instance = nullptr;
  40. if (instance == nullptr) {
  41. instance = new DetectManager();
  42. }
  43. return instance;
  44. }
  45. ~DetectManager() = default;
  46. Error_manager Init();
  47. Error_manager Release();
  48. MeasureStatu getMeasureResult(DetectResult &result);
  49. Error_manager carMoveStatus();
  50. protected:
  51. void run();
  52. void stop();
  53. // 车轮点云优化
  54. Error_manager WheelCloudOptimize(std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> &vct_wheel_cloud, DetectResult &result);
  55. private:
  56. std::thread *m_thread;
  57. Thread_condition m_condit;
  58. TimedLockData<bool> move_statu;
  59. TimedLockData<MeasureStatu> detect_statu;
  60. TensorrtWheelDetector *detector;
  61. TimedLockData<DetectResult> m_detect_result_time_lock_data;
  62. };