data_def_api.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #pragma once
  2. #include <string>
  3. namespace graft_cv{
  4. typedef unsigned char byte;
  5. typedef struct
  6. {
  7. int angle;
  8. int width;
  9. int height;
  10. byte *data;
  11. }ImgInfo;
  12. typedef struct{
  13. // 调试控制 (5)
  14. bool image_show;//true--显示处理过程中的中间图片,需要人工回车才能继续执行; false--无图片显示
  15. bool image_return;//true--返回结果positoninfo中添加返回的图片; false--无图片返回
  16. int image_row_grid;
  17. int image_col_grid;
  18. bool self_camera;
  19. // timeout (2)
  20. int timeout_proc; //单个接口处理时间,500ms
  21. int timeout_append; //100ms
  22. //image storage parameters(3)
  23. bool image_save;//是否保存图像
  24. std::string image_depository;//保存图像目录
  25. int image_backup_days;//保存图像天数,过期删除
  26. // optimal angle parameters (15)
  27. bool oa_y_flip;
  28. int oa_morph_radius;//optimal-angle, open-operation morph-size, = 1;-->COptimalAngle::imgproc(Mat& img)
  29. int oa_morph_iteration; //optimal-angle, open-operation times, = 5; -->COptimalAngle::imgproc(Mat& img)
  30. int oa_min_hist_value;// optimal-angle, columns-histogram, threshold; -->COptimalAngle::imgproc(Mat& img)
  31. double oa_col_th_ratio;// = 0.7, rootstock binary image column histogram, threshold ratio for max-value, for
  32. // detect stem x-range
  33. double oa_row_th_ratio; // = 1.2, row histogram of stem x-range subimage, stem diameter ratio for detect
  34. // stem fork position
  35. int oa_stem_x_padding; // = 20;
  36. int oa_stem_dia_min; //=20,
  37. int oa_stem_fork_y_min;//=10,茎分叉点到茎根最下像素数量
  38. double oa_stem_dia_mp; //=0.8,
  39. int oa_morph_radius_base;//基质二值化参数
  40. int oa_morph_iteration_base; //基质二值化参数
  41. int oa_min_hist_value_base;//基质二值化参数
  42. int oa_clip_y_min;//定位夹子上边缘y值
  43. int oa_clip_y_max;//定位夹子下边缘y值
  44. //rootstock cut parameters (20)
  45. bool rs_y_flip;
  46. int rs_min_hist_value;
  47. double rs_col_th_ratio;// = 0.7, rootstock binary image column histogram, threshold ratio for max-value, for
  48. // detect stem x-range
  49. double rs_row_th_ratio; // = 1.2, row histogram of stem x-range subimage, stem diameter ratio for detect
  50. // stem fork position
  51. int rs_stem_x_padding; // = 20;
  52. int rs_stem_dia_min; //=20,
  53. double rs_stem_dia_mp; //=0.8,
  54. int rs_stem_fork_y_min;//=10,茎分叉点到茎根最下像素数量
  55. int rs_stem_edge_detect_window;//=5, 茎单侧边缘点检测,检测时的窗口像素数量
  56. //和茎粗相关,此数据应小于茎粗(像素数)
  57. double rs_cand_corner_box_width_ratio;//=3.0 基于茎fork点,茎右侧边缘点为参考点,检测候选角点区域, 茎粗的倍数
  58. double rs_cand_corner_box_xoffset_ratio;//=-10,cand_corner_box x方向偏移量, 茎粗的倍数
  59. double rs_opt_corner_xoffset_ratio;//=0.75, 最优切割角点,与参考点间的距离,与茎粗的比率,也就是
  60. // 最优切割点距离参考点有几倍的茎粗
  61. double rs_opt_corner_yoffset_ratio;
  62. double rs_corner_mask_rad_ratio;//二值图像角点检测后,度量角点质量用模板半径系数,为茎粗的几倍
  63. int rs_morph_radius;//=1, open-operation morph-size, = 1;-->COptimalAngle::imgproc(Mat& img)
  64. int rs_morph_iteration;// = 2
  65. int rs_morph_iteration_gray;//=5
  66. int rs_max_corner_num;//=100;
  67. double rs_corner_qaulity_level;// = 0.1;
  68. double rs_corner_min_distance;// = 10;
  69. double rs_cut_angle; //=-135 以上切割点为中心,切削茎的方向,(-180.0,180.0)
  70. double rs_cut_point_offset_ratio;//向下偏移比例,内接圆半径的倍数0-1.0
  71. //scion cut parameters (14)
  72. bool sc_y_flip;
  73. double sc_col_th_ratio;// = 0.7, scion binary image column histogram, threshold ratio for max-value, for
  74. // detect stem x-range
  75. double sc_row_th_ratio; // = 0.66, row histogram of stem x-range subimage, stem diameter ratio for detect
  76. // stem fork position, x0----x1范围内横向投影,投影值除以(x1-x0)大于此系数即找到边界
  77. int sc_stem_x_padding; // = 50;
  78. int sc_stem_dia_min; //=20,
  79. int sc_clip_padding;//=5 夹子向下间隔,这个间隔向下开始当做茎来处理
  80. int sc_stem_ymax_padding;//=50 第一次检测到茎最下端(因夹子影响,茎偏小),加大检测范围
  81. int sc_default_cut_length;//如果没有找到fold_point,直接估计出fold_point
  82. int sc_stem_edge_detect_window;//=5, 茎单侧边缘点检测,检测时的窗口像素数量
  83. //和茎粗相关,此数据应小于茎粗(像素数)
  84. double sc_r2_th; //threshold for r2 ratio
  85. int sc_r2_window; //= 5; the radius for calculate r2 index
  86. int sc_average_window;// =10;
  87. int sc_morph_radius;//scion, open-operation morph-size, = 1;-->COptimalAngle::imgproc(Mat& img)
  88. int sc_morph_iteration; //scion, open-operation times, = 5; -->COptimalAngle::imgproc(Mat& img)
  89. // camera pixel ratio (3)
  90. double rs_oa_pixel_ratio; // rootstock optimal-angle camera pixel ratio for millimeter, mm/piexel
  91. double rs_cut_pixel_ratio; // rootstock cutting camera pixel ratio for millimeter, mm/piexel
  92. double sc_cut_pixel_ratio; // scion cutting camera pixel ratio for millimeter, mm/piexel
  93. } ConfigParam;
  94. typedef struct
  95. {
  96. //以下涉及到位置均为实际位置,毫米
  97. double rs_oa;//砧木最优角度
  98. double rs_oa_base;//砧木基质最优角度
  99. double rs_oa_stem_y_fork;//茎分叉点y,毫米
  100. double rs_oa_clamp_y_end;//茎可视下端y,毫米
  101. int rs_oa_width;//每一帧返回叶展宽度
  102. int rs_oa_width_base;//每一帧返回基质宽度
  103. double rs_cut_upoint_x;//砧木上切割点x位置,毫米
  104. double rs_cut_upoint_y;//砧木上切割点y位置,毫米
  105. double rs_stem_diameter;//砧木茎粗,毫米
  106. double rs_cut_lpoint_x;//砧木下切割点x位置,毫米
  107. double rs_cut_lpoint_y;//砧木下切割点y位置,毫米
  108. double sc_cut_upoint_x;//穗苗上切割点x位置,毫米
  109. double sc_cut_upoint_y;//穗苗上切割点y位置,毫米
  110. double sc_cut_cpoint_x;//穗苗切割中点x位置,毫米
  111. double sc_cut_cpoint_y;//穗苗切割中点y位置,毫米
  112. double sc_cut_lpoint_x;//穗苗切割下点x位置,毫米
  113. double sc_cut_lpoint_y;//穗苗切割下点y位置,毫米
  114. ImgInfo* pp_images[5];//参考图片,只读,从前向后,没有的会被置零
  115. }PositionInfo;
  116. };