graft_cv_api.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. GCV_API int cv_set_param_from_file(char*conf_file);
  36. //6 接口退出前的释放
  37. GCV_API int cv_release();
  38. //7 获取当前配置文件路径,输入char*要空间足够,内部没有检测是否越界
  39. GCV_API void cv_get_conf_file(char*);
  40. //8 保存到本地配置文件中(覆盖)
  41. GCV_API void cv_save_param(char* conf_file/*=0*/);
  42. //9 获取当前的配置参数
  43. GCV_API void cv_get_param(ConfigParam&);
  44. //10 获取当前版本号,char*要空间足够,内部没有检测是否越界
  45. GCV_API void get_version(char* buf);
  46. //11 茄科上苗,找到抓取位置
  47. //
  48. // 输入: points --- 输入, 指向点云的指针,点云为3值一组,结构:[pt0.x, pt0.y, pt0.z, pt1.x, pt1.y,pt1.z], 有时是4值一组(视采集设备数据情况)
  49. // pixel_size --- 输入,一个点云的维度(一般3或4)
  50. // pt_size-------- 输入, 点云数量,上例中数量为2
  51. // dtype -------- 输入,砧木--0, 穗苗--1
  52. //
  53. // posinfo ------- 输出
  54. // fn ------------ 输入, points指向0,且fn可用时,读取文件中的数据(用于测试),仅支持ply格式
  55. // posinfo.rs_pre_x;
  56. // posinfo.rs_pre_y;
  57. // posinfo.rs_pre_z;
  58. // 其余数据为0
  59. // 返回: 0- 正常; 其他- 失败
  60. GCV_API int sola_grab_point(float* points, int pixel_size, int pt_size, int dtype, PositionInfo& posinfo, const char* fn=0);
  61. //12 砧木最优角度识别,追加图像,要求图像的角度按顺序,第一帧图像角度为0,最后一帧图像角度为180
  62. // 每次追加图片,通过posinfo返回:
  63. // 1)叶展宽度posinfo.rs_oa_width;
  64. // 2) 基质宽度posinfo.rs_oa_width_base
  65. // 3) 茎分叉点y posinfo.rs_oa_stem_y_fork;//茎分叉点y,毫米
  66. // 4) 茎可视下端y posinfo.rs_oa_clamp_y_end;//茎可视下端y,毫米
  67. // 5)2帧图像:posinfo.pp_images[0]--砧木分割二值图像 (return image 为 true时)
  68. // posinfo.pp_images[1]--基质分割二值图像
  69. // 返回: 0- 正常; 1- 失败
  70. //GCV_API int rs_oa_append(ImgInfo*, PositionInfo& posinfo);
  71. //13 获取砧木最优角度
  72. // ImgInfo* 为输出顶部拍照的图片
  73. // 返回posinfo.rs_oa, 需要旋转的角度,逆时针为正方向
  74. // 返回: 0- 正常; 1- 失败
  75. GCV_API int rs_oa_get_result(ImgInfo*, PositionInfo& posinfo);
  76. //14 砧木切割点识别,返回
  77. // posinfo.rs_img_id
  78. // posinfo.rs_cut_upoint_x
  79. // posinfo.rs_cut_upoint_y
  80. // posinfo.rs_stem_diameter
  81. // posinfo.rs_cut_lpoint_x
  82. // posinfo.rs_cut_lpoint_y
  83. // posinfo.pp_images (return image 为 true时)
  84. // 返回3张图片:图0:二值图像,含茎x-range,茎分叉点右侧边缘坐标(circle中心)
  85. // 图1: 灰度图,候选角点(circle),候选框,参考点(茎分叉点右侧边缘坐标)
  86. // 图2:灰度图,上切割点,候选框,参考点,下切点(circle中心),根点(circle中心)
  87. // 返回: 0- 正常; 1- 失败
  88. GCV_API int rs_cut_point(ImgInfo*, PositionInfo& posinfo);
  89. //15 砧木切割点切后识别,返回
  90. // posinfo.rs_becut_upoint_x
  91. // posinfo.rs_becut_upoint_y
  92. // posinfo.pp_images (return image 为 true时)
  93. // 返回1张图片:图0:二值图像,含茎x-range,上切点(circle中心),下切点(circle中心),根点(circle中心)
  94. //
  95. // 返回: 0- 正常; 1- 失败
  96. GCV_API int rs_cut_point_reid(ImgInfo*, const char* pre_img_id, PositionInfo& posinfo);
  97. //16 茄科切割点切后识别
  98. // input:
  99. // ImgInfo* --- 输入图像
  100. // sola_type --- 0--砧木; 1---穗苗
  101. // posinfo---- 返回信息
  102. //
  103. // 返回
  104. // 上切点,中切点,下切点
  105. //
  106. // posinfo.pp_images (return image 为 true时)
  107. // 返回2张图片:图0:二值图像
  108. // 图1: 灰度图像,拟合椭圆
  109. //
  110. // 返回: 0- 正常; 1- 失败
  111. GCV_API int sola_cut_point_reid(ImgInfo*, int sola_type, PositionInfo& posinfo);
  112. //17 穗苗上切割点识别,返回
  113. // posinfo.sc_cut_upoint_x;
  114. // posinfo.sc_cut_upoint_y;
  115. // posinfo.sc_cut_cpoint_x;
  116. // posinfo.sc_cut_cpoint_y;
  117. // posinfo.pp_images (return image 为 true时)
  118. // 返回1张图片:图0:二值图像,含茎x-range,茎分叉点水平线,尖点水平线,上切点(circle中心),中切点(circle中心)
  119. //
  120. // 返回: 0- 正常; 1- 失败
  121. GCV_API int sc_cut_point(ImgInfo*, PositionInfo& posinfo);
  122. };//namespace graft_cv
  123. #ifdef __cplusplus
  124. }
  125. #endif