#pragma once #include namespace graft_cv{ typedef unsigned char byte; typedef struct { int angle; int width; int height; byte *data; }ImgInfo; typedef struct{ // 调试控制 (5) bool image_show;//true--显示处理过程中的中间图片,需要人工回车才能继续执行; false--无图片显示 bool image_return;//true--返回结果positoninfo中添加返回的图片; false--无图片返回 int image_row_grid; int image_col_grid; bool self_camera; // timeout (2) int timeout_proc; //单个接口处理时间,500ms int timeout_append; //100ms //image storage parameters(3) bool image_save;//是否保存图像 std::string image_depository;//保存图像目录 int image_backup_days;//保存图像天数,过期删除 // optimal angle parameters (15) bool oa_y_flip; int oa_morph_radius;//optimal-angle, open-operation morph-size, = 1;-->COptimalAngle::imgproc(Mat& img) int oa_morph_iteration; //optimal-angle, open-operation times, = 5; -->COptimalAngle::imgproc(Mat& img) int oa_min_hist_value;// optimal-angle, columns-histogram, threshold; -->COptimalAngle::imgproc(Mat& img) double oa_col_th_ratio;// = 0.7, rootstock binary image column histogram, threshold ratio for max-value, for // detect stem x-range double oa_row_th_ratio; // = 1.2, row histogram of stem x-range subimage, stem diameter ratio for detect // stem fork position int oa_stem_x_padding; // = 20; int oa_stem_dia_min; //=20, int oa_stem_fork_y_min;//=10,茎分叉点到茎根最下像素数量 double oa_stem_dia_mp; //=0.8, int oa_morph_radius_base;//基质二值化参数 int oa_morph_iteration_base; //基质二值化参数 int oa_min_hist_value_base;//基质二值化参数 int oa_clip_y_min;//定位夹子上边缘y值 int oa_clip_y_max;//定位夹子下边缘y值 //rootstock cut parameters (20) bool rs_y_flip; int rs_min_hist_value; double rs_col_th_ratio;// = 0.7, rootstock binary image column histogram, threshold ratio for max-value, for // detect stem x-range double rs_row_th_ratio; // = 1.2, row histogram of stem x-range subimage, stem diameter ratio for detect // stem fork position int rs_stem_x_padding; // = 20; int rs_stem_dia_min; //=20, double rs_stem_dia_mp; //=0.8, int rs_stem_fork_y_min;//=10,茎分叉点到茎根最下像素数量 int rs_stem_edge_detect_window;//=5, 茎单侧边缘点检测,检测时的窗口像素数量 //和茎粗相关,此数据应小于茎粗(像素数) double rs_cand_corner_box_width_ratio;//=3.0 基于茎fork点,茎右侧边缘点为参考点,检测候选角点区域, 茎粗的倍数 double rs_cand_corner_box_xoffset_ratio;//=-10,cand_corner_box x方向偏移量, 茎粗的倍数 double rs_opt_corner_xoffset_ratio;//=0.75, 最优切割角点,与参考点间的距离,与茎粗的比率,也就是 // 最优切割点距离参考点有几倍的茎粗 double rs_opt_corner_yoffset_ratio; double rs_corner_mask_rad_ratio;//二值图像角点检测后,度量角点质量用模板半径系数,为茎粗的几倍 int rs_morph_radius;//=1, open-operation morph-size, = 1;-->COptimalAngle::imgproc(Mat& img) int rs_morph_iteration;// = 2 int rs_morph_iteration_gray;//=5 int rs_max_corner_num;//=100; double rs_corner_qaulity_level;// = 0.1; double rs_corner_min_distance;// = 10; double rs_cut_angle; //=-135 以上切割点为中心,切削茎的方向,(-180.0,180.0) double rs_cut_point_offset_ratio;//向下偏移比例,内接圆半径的倍数0-1.0 //scion cut parameters (14) bool sc_y_flip; double sc_col_th_ratio;// = 0.7, scion binary image column histogram, threshold ratio for max-value, for // detect stem x-range double sc_row_th_ratio; // = 0.66, row histogram of stem x-range subimage, stem diameter ratio for detect // stem fork position, x0----x1范围内横向投影,投影值除以(x1-x0)大于此系数即找到边界 int sc_stem_x_padding; // = 50; int sc_stem_dia_min; //=20, int sc_clip_padding;//=5 夹子向下间隔,这个间隔向下开始当做茎来处理 int sc_stem_ymax_padding;//=50 第一次检测到茎最下端(因夹子影响,茎偏小),加大检测范围 int sc_default_cut_length;//如果没有找到fold_point,直接估计出fold_point int sc_stem_edge_detect_window;//=5, 茎单侧边缘点检测,检测时的窗口像素数量 //和茎粗相关,此数据应小于茎粗(像素数) double sc_r2_th; //threshold for r2 ratio int sc_r2_window; //= 5; the radius for calculate r2 index int sc_average_window;// =10; int sc_morph_radius;//scion, open-operation morph-size, = 1;-->COptimalAngle::imgproc(Mat& img) int sc_morph_iteration; //scion, open-operation times, = 5; -->COptimalAngle::imgproc(Mat& img) // camera pixel ratio (3) double rs_oa_pixel_ratio; // rootstock optimal-angle camera pixel ratio for millimeter, mm/piexel double rs_cut_pixel_ratio; // rootstock cutting camera pixel ratio for millimeter, mm/piexel double sc_cut_pixel_ratio; // scion cutting camera pixel ratio for millimeter, mm/piexel } ConfigParam; typedef struct { //以下涉及到位置均为实际位置,毫米 double rs_oa;//砧木最优角度 double rs_oa_base;//砧木基质最优角度 double rs_oa_stem_y_fork;//茎分叉点y,毫米 double rs_oa_clamp_y_end;//茎可视下端y,毫米 int rs_oa_width;//每一帧返回叶展宽度 int rs_oa_width_base;//每一帧返回基质宽度 double rs_cut_upoint_x;//砧木上切割点x位置,毫米 double rs_cut_upoint_y;//砧木上切割点y位置,毫米 double rs_stem_diameter;//砧木茎粗,毫米 double rs_cut_lpoint_x;//砧木下切割点x位置,毫米 double rs_cut_lpoint_y;//砧木下切割点y位置,毫米 double sc_cut_upoint_x;//穗苗上切割点x位置,毫米 double sc_cut_upoint_y;//穗苗上切割点y位置,毫米 double sc_cut_cpoint_x;//穗苗切割中点x位置,毫米 double sc_cut_cpoint_y;//穗苗切割中点y位置,毫米 double sc_cut_lpoint_x;//穗苗切割下点x位置,毫米 double sc_cut_lpoint_y;//穗苗切割下点y位置,毫米 ImgInfo* pp_images[5];//参考图片,只读,从前向后,没有的会被置零 }PositionInfo; };