graft_cv_api.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Grafting is the process of joining two plants together
  2. //(an upper portion and a lower portion) to grow as one.
  3. //The upper portion of the plant is known as the scion,
  4. //which is attached to the lower portion known as the rootstock.
  5. //rs -- rootstock, sc -- scion
  6. #pragma once
  7. #include "data_def_api.h"
  8. using namespace std;
  9. //定义GCV_DEBUG,每一步图像处理都会输出中间结果图片显示(opencv),回车后继续执行,用于测试
  10. // #define GCV_DEBUG
  11. // export
  12. #define GCV_EXPORTS
  13. #ifdef GCV_EXPORTS
  14. #define GCV_API __declspec(dllexport)
  15. #else
  16. #define GCV_API __declspec(dllimport)
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C"
  20. {
  21. #endif
  22. namespace graft_cv
  23. {
  24. //1 设置log路径
  25. GCV_API int cv_set_logpath(char*lpath);
  26. //2 设置log等级
  27. GCV_API int cv_set_loglevel(int lev);// 0-debug, 1-info, 2-warning, 3-error
  28. //3 设置是否存储图片(存储路径在configure文件中),true--保存,false--不保存
  29. GCV_API int cv_init_image_saver();
  30. //4 初始化:本地配置文件初始化(yml)
  31. // 返回: 0- 正常; 1- 配置文件不存在
  32. GCV_API int cv_init(char*conf_file);
  33. //5 初始化:通过ConfigParam结构体对象直接赋值配置参数(内存)
  34. GCV_API void cv_set_param(ConfigParam&);
  35. //6 接口退出前的释放
  36. GCV_API int cv_release();
  37. //7 获取当前配置文件路径,输入char*要空间足够,内部没有检测是否越界
  38. GCV_API void cv_get_conf_file(char*);
  39. //8 保存到本地配置文件中(覆盖)
  40. GCV_API void cv_save_param(char* conf_file/*=0*/);
  41. //9 获取当前的配置参数
  42. GCV_API void cv_get_param(ConfigParam&);
  43. //10 获取当前版本号,char*要空间足够,内部没有检测是否越界
  44. GCV_API void get_version(char* buf);
  45. //11 砧木最优角度识别初始化,每一株均需初始化一次
  46. // 返回: 0- 正常; 其他- 失败
  47. GCV_API int rs_oa_init();
  48. //12 砧木最优角度识别,追加图像,要求图像的角度按顺序,第一帧图像角度为0,最后一帧图像角度为180
  49. // 每次追加图片,通过posinfo返回:
  50. // 1)叶展宽度posinfo.rs_oa_width;
  51. // 2) 基质宽度posinfo.rs_oa_width_base
  52. // 3) 茎分叉点y posinfo.rs_oa_stem_y_fork;//茎分叉点y,毫米
  53. // 4) 茎可视下端y posinfo.rs_oa_clamp_y_end;//茎可视下端y,毫米
  54. // 5)2帧图像:posinfo.pp_images[0]--砧木分割二值图像 (return image 为 true时)
  55. // posinfo.pp_images[1]--基质分割二值图像
  56. // 返回: 0- 正常; 1- 失败
  57. GCV_API int rs_oa_append(ImgInfo*, PositionInfo& posinfo);
  58. //13 获取砧木最优角度
  59. // 返回posinfo.rs_oa,
  60. // posinfo.rs_oa_base
  61. // posinfo.rs_oa_stem_y_fork,
  62. // posinfo.rs_oa_clamp_y_end,
  63. // 返回: 0- 正常; 1- 失败
  64. GCV_API int rs_oa_get_result(PositionInfo& posinfo);
  65. //14 砧木切割点识别,返回
  66. // posinfo.rs_cut_edge_length
  67. // posinfo.rs_cut_upoint_x
  68. // posinfo.rs_cut_upoint_y
  69. // posinfo.rs_stem_diameter
  70. // posinfo.pp_images (return image 为 true时)
  71. // 返回3张图片:图0:二值图像,含茎x-range,茎分叉点右侧边缘坐标(circle中心)
  72. // 图1: 灰度图,候选角点(circle),候选框,参考点(茎分叉点右侧边缘坐标)
  73. // 图2:灰度图,上切割点,候选框,参考点,下切点(circle中心),根点(circle中心)
  74. // 返回: 0- 正常; 1- 失败
  75. GCV_API int rs_cut_point(ImgInfo*, PositionInfo& posinfo);
  76. //15 砧木切割点切后识别,返回
  77. // posinfo.rs_becut_upoint_x
  78. // posinfo.rs_becut_upoint_y
  79. // posinfo.pp_images (return image 为 true时)
  80. // 返回1张图片:图0:二值图像,含茎x-range,上切点(circle中心),下切点(circle中心),根点(circle中心)
  81. //
  82. // 返回: 0- 正常; 1- 失败
  83. //GCV_API int rs_cut_point_reid(ImgInfo*, double edge_length, PositionInfo& posinfo);
  84. //16 穗苗上切割点识别,返回
  85. // posinfo.sc_cut_upoint_x;
  86. // posinfo.sc_cut_upoint_y;
  87. // posinfo.sc_cut_cpoint_x;
  88. // posinfo.sc_cut_cpoint_y;
  89. // posinfo.pp_images (return image 为 true时)
  90. // 返回1张图片:图0:二值图像,含茎x-range,茎分叉点水平线,尖点水平线,上切点(circle中心),中切点(circle中心)
  91. //
  92. // 返回: 0- 正常; 1- 失败
  93. GCV_API int sc_cut_point(ImgInfo*, PositionInfo& posinfo);
  94. };//namespace graft_cv
  95. #ifdef __cplusplus
  96. }
  97. #endif