graft_cv_api.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_rs(float* points, int pixel_size, int pt_size, PositionInfo& posinfo, const char* fn=0);
  61. GCV_API int sola_grab_point_sc(float* points, int pixel_size, int pt_size, PositionInfo& posinfo, const char* fn = 0);
  62. GCV_API int chessboard_calibration(float* points, int pixel_size, int pt_size, PositionInfo& posinfo, const char* fn = 0);
  63. //12 砧木最优角度识别,追加图像,要求图像的角度按顺序,第一帧图像角度为0,最后一帧图像角度为180
  64. // 每次追加图片,通过posinfo返回:
  65. // 1)叶展宽度posinfo.rs_oa_width;
  66. // 2) 基质宽度posinfo.rs_oa_width_base
  67. // 3) 茎分叉点y posinfo.rs_oa_stem_y_fork;//茎分叉点y,毫米
  68. // 4) 茎可视下端y posinfo.rs_oa_clamp_y_end;//茎可视下端y,毫米
  69. // 5)2帧图像:posinfo.pp_images[0]--砧木分割二值图像 (return image 为 true时)
  70. // posinfo.pp_images[1]--基质分割二值图像
  71. // 返回: 0- 正常; 1- 失败
  72. //GCV_API int rs_oa_append(ImgInfo*, PositionInfo& posinfo);
  73. //13 获取砧木最优角度
  74. // ImgInfo* 为输出顶部拍照的图片
  75. // 返回posinfo.rs_oa, 需要旋转的角度,逆时针为正方向
  76. // 返回: 0- 正常; 1- 失败
  77. GCV_API int rs_oa_get_result(ImgInfo*, PositionInfo& posinfo);
  78. //14 砧木切割点识别,返回
  79. // posinfo.rs_img_id
  80. // posinfo.rs_cut_upoint_x
  81. // posinfo.rs_cut_upoint_y
  82. // posinfo.rs_stem_diameter
  83. // posinfo.rs_cut_lpoint_x
  84. // posinfo.rs_cut_lpoint_y
  85. // posinfo.pp_images (return image 为 true时)
  86. // 返回3张图片:图0:二值图像,含茎x-range,茎分叉点右侧边缘坐标(circle中心)
  87. // 图1: 灰度图,候选角点(circle),候选框,参考点(茎分叉点右侧边缘坐标)
  88. // 图2:灰度图,上切割点,候选框,参考点,下切点(circle中心),根点(circle中心)
  89. // 返回: 0- 正常; 1- 失败
  90. GCV_API int rs_cut_point(ImgInfo*, PositionInfo& posinfo);
  91. //15 砧木切割点切后识别,返回
  92. // posinfo.rs_becut_upoint_x
  93. // posinfo.rs_becut_upoint_y
  94. // posinfo.pp_images (return image 为 true时)
  95. // 返回1张图片:图0:二值图像,含茎x-range,上切点(circle中心),下切点(circle中心),根点(circle中心)
  96. //
  97. // 返回: 0- 正常; 1- 失败
  98. GCV_API int rs_cut_point_reid(ImgInfo*, const char* pre_img_id, PositionInfo& posinfo);
  99. //16 茄科切割点切后识别
  100. // input:
  101. // ImgInfo* --- 输入图像
  102. // sola_type --- 0---穗苗; 1--砧木
  103. // posinfo---- 返回信息
  104. //
  105. // 返回
  106. // 上切点,中切点,下切点
  107. // //砧木,坐标左下角位0点
  108. // posinfo.rs_reid_sola_upoint_x; //base_y, 夹爪基面的y像素坐标, 砧木在下方(夹爪的上沿),接穗在上方(夹爪的下沿)
  109. // posinfo.rs_reid_sola_upoint_y; //上切割点y像素坐标与base_y的像素距离
  110. // posinfo.rs_reid_sola_cpoint_x; //--------------------无意义(目标框x)
  111. // posinfo.rs_reid_sola_cpoint_y; //中切割点y像素坐标与base_y的像素距离
  112. // posinfo.rs_reid_sola_lpoint_x; //--------------------无意义(目标框x)
  113. // posinfo.rs_reid_sola_lpoint_y; //下切割点y像素坐标与base_y的像素距离
  114. //
  115. // //接穗,坐标左上角位0点
  116. // posinfo.sc_reid_sola_upoint_x; //base_y, 夹爪基面的y像素坐标, 砧木在下方(夹爪的上沿),接穗在上方(夹爪的下沿)
  117. // posinfo.sc_reid_sola_upoint_y; //上切割点y像素坐标与base_y的像素距离
  118. // posinfo.sc_reid_sola_cpoint_x; //--------------------无意义(目标框x)
  119. // posinfo.sc_reid_sola_cpoint_y; //中切割点y像素坐标与base_y的像素距离
  120. // posinfo.sc_reid_sola_lpoint_x; //--------------------无意义(目标框x)
  121. // posinfo.sc_reid_sola_lpoint_y; //下切割点y像素坐标与base_y的像素距离
  122. //
  123. // posinfo.pp_images (return image 为 true时)
  124. // 返回2张图片:图0:二值图像
  125. // 图1: 灰度图像,拟合椭圆
  126. //
  127. // 返回: 0- 正常; 1- 失败
  128. GCV_API int sola_cut_point_reid_rs(ImgInfo*, PositionInfo& posinfo);
  129. GCV_API int sola_cut_point_reid_sc(ImgInfo*, PositionInfo& posinfo);
  130. //17 穗苗上切割点识别,返回
  131. // posinfo.sc_cut_upoint_x;
  132. // posinfo.sc_cut_upoint_y;
  133. // posinfo.sc_cut_cpoint_x;
  134. // posinfo.sc_cut_cpoint_y;
  135. // posinfo.pp_images (return image 为 true时)
  136. // 返回1张图片:图0:二值图像,含茎x-range,茎分叉点水平线,尖点水平线,上切点(circle中心),中切点(circle中心)
  137. //
  138. // 返回: 0- 正常; 1- 失败
  139. GCV_API int sc_cut_point(ImgInfo*, PositionInfo& posinfo);
  140. };//namespace graft_cv
  141. #ifdef __cplusplus
  142. }
  143. #endif