Terminal_region_limit.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // Created by zx on 2020/1/16.
  3. //
  4. #include "Terminal_region_limit.h"
  5. Terminal_region_limit::Terminal_region_limit(Railing* left_railing,Railing* right_railing)
  6. {
  7. mp_left_railing=left_railing;
  8. mp_right_railing=right_railing;
  9. }
  10. Error_manager Terminal_region_limit::verify(cv::RotatedRect rect)
  11. {
  12. if(mp_right_railing==NULL || mp_left_railing==NULL)
  13. {
  14. return Error_manager(PARAMETER_ERROR,NORMAL,"terminal left or right railing is null");
  15. }
  16. Error_manager code;
  17. bool tb_left_error=false;
  18. bool tb_right_error=false;
  19. code=mp_left_railing->verify(rect);
  20. if(code!=SUCCESS)
  21. {
  22. //左边栏杆碰撞
  23. tb_left_error=true;
  24. }
  25. code=mp_right_railing->verify(rect);
  26. if(code!=SUCCESS)
  27. {
  28. //右边栏杆碰撞
  29. tb_right_error=true;
  30. }
  31. if(tb_left_error && tb_right_error)
  32. {
  33. return Error_manager(HARDWARE_LIMIT_TERMINAL_LR_ERROR,NORMAL,"terminal left and right railing error");
  34. }
  35. if(tb_left_error)
  36. {
  37. return Error_manager(HARDWARE_LIMIT_TERMINAL_LEFT_ERROR,NORMAL,"terminal left railing error");
  38. }
  39. if(tb_right_error)
  40. {
  41. return Error_manager(HARDWARE_LIMIT_TERMINAL_RIGHT_ERROR,NORMAL,"terminal right railing error");
  42. }
  43. return SUCCESS;
  44. }