data_def.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #pragma once
  2. namespace graft_cv{
  3. extern char *g_version_str;
  4. //enum camera {rs_clamp_rad, rs_clamp_tan, rs_cut_rad, rs_cut_tan, sc_clamp_rad, sc_clamp_tan, sc_cut_rad, sc_cut_tan};
  5. enum img_type {oa,rs,rs_reid,sc,sola_rs_reid, sola_sc_reid, sola_rs_pcd, sola_sc_pcd, tea_grab,tea_cut};
  6. template<class T>
  7. class roi_box{
  8. public:
  9. roi_box(T x_, T y_, T width_, T height_){
  10. this->x = x_;
  11. this->y = y_;
  12. this->width = width_;
  13. this->height = height_;
  14. }
  15. roi_box(){
  16. this->x = T(0);
  17. this->y = T(0);
  18. this->width = T(0);
  19. this->height = T(0);
  20. }
  21. ~roi_box(){}
  22. bool isInBox(T pt_x, T pt_y){
  23. if (pt_x>=this->x && pt_x <=(this->x+this->width) &&
  24. pt_y >= this->y && pt_y <= (this->y + this->height)){
  25. return true;
  26. }
  27. else{
  28. return false;
  29. }
  30. }
  31. private:
  32. T x;
  33. T y;
  34. T width;
  35. T height;
  36. };
  37. template<class T>
  38. class gcv_point{
  39. public:
  40. gcv_point(T x_, T y_){
  41. this->x = x_;
  42. this->y = y_;
  43. }
  44. gcv_point(){
  45. this->x = T(0);
  46. this->y = T(0);
  47. }
  48. gcv_point(const gcv_point<T>&pt){
  49. this->x = pt.x;
  50. this->y = pt.y;
  51. }
  52. ~gcv_point(){}
  53. double distance(const gcv_point<T>& pt)const
  54. {
  55. return sqrt((double)(this->x - pt.x)*(this->x - pt.x) +
  56. (double)(this->y - pt.y)*(this->y - pt.y));
  57. }
  58. gcv_point<T>& operator=(const gcv_point<T>& pt)
  59. {
  60. if(this !=&pt){
  61. this->x=pt.x;
  62. this->y=pt.y;
  63. }
  64. return *this;
  65. }
  66. bool operator==(const gcv_point<T>& pt)const
  67. {
  68. if(this->x==pt.x && this->y==pt.y){
  69. return true;
  70. }
  71. return false;
  72. }
  73. public:
  74. T x;
  75. T y;
  76. };
  77. struct Bbox //drop box with confidence and center keypoint
  78. {
  79. Bbox() {
  80. this->score = 0.0;
  81. this->score_overall = 0.0;
  82. this->x1 = 0;
  83. this->y1 = 0;
  84. this->x2 = 0;
  85. this->y2 = 0;
  86. for (int i = 0; i < 10; ++i) {
  87. this->ppoint[i] = 0.0;
  88. }
  89. for (int i = 0; i < 2; ++i) {
  90. this->operate_point[i] = 0.0;
  91. }
  92. this->operate_angle = 0.0;
  93. this->area = 0.0;
  94. this->status = 0;
  95. }
  96. Bbox(const Bbox& another)
  97. {
  98. this->score = another.score;
  99. this->score_overall = another.score_overall;
  100. this->x1 = another.x1;
  101. this->y1 = another.y1;
  102. this->x2 = another.x2;
  103. this->y2 = another.y2;
  104. for (int i = 0; i < 10; ++i) {
  105. this->ppoint[i] = another.ppoint[i];
  106. }
  107. for (int i = 0; i < 2; ++i) {
  108. this->operate_point[i] = another.operate_point[i];
  109. }
  110. this->operate_angle = another.operate_angle;
  111. this->area = another.area;
  112. this->status = another.status;
  113. }
  114. float score;//目标识别得分
  115. float score_overall;//识别成功后,优先抓取得分,综合得分
  116. int x1;
  117. int y1;
  118. int x2;
  119. int y2;
  120. float ppoint[10]; //(x,y) 5 key points
  121. float operate_point[2]; //(x,y) 1 operate point, 操作点
  122. float operate_angle; //angle of operate point, 操作点的角度方向
  123. float area; //像素面积
  124. int status; // 状态:未选中=0;被选中=1;
  125. };
  126. };