123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- // Grafting is the process of joining two plants together
- //(an upper portion and a lower portion) to grow as one.
- //The upper portion of the plant is known as the scion,
- //which is attached to the lower portion known as the rootstock.
- //rs -- rootstock, sc -- scion
- #pragma once
- #include "data_def_api.h"
- using namespace std;
- //定义GCV_DEBUG,每一步图像处理都会输出中间结果图片显示(opencv),回车后继续执行,用于测试
- // #define GCV_DEBUG
- // export
- #define GCV_EXPORTS
- #ifdef GCV_EXPORTS
- #define GCV_API __declspec(dllexport)
- #else
- #define GCV_API __declspec(dllimport)
- #endif
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- namespace graft_cv
- {
- //1 设置log路径
- GCV_API int cv_set_logpath(char*lpath);
- //2 设置log等级
- GCV_API int cv_set_loglevel(int lev);// 0-debug, 1-info, 2-warning, 3-error
- //3 设置是否存储图片(存储路径在configure文件中),true--保存,false--不保存
- GCV_API int cv_init_image_saver();
- //4 初始化:本地配置文件初始化(yml)
- // 返回: 0- 正常; 1- 配置文件不存在
- GCV_API int cv_init(char*conf_file);
- //5 初始化:通过ConfigParam结构体对象直接赋值配置参数(内存)
- GCV_API void cv_set_param(ConfigParam&);
- GCV_API int cv_set_param_from_file(char*conf_file);
- //6 接口退出前的释放
- GCV_API int cv_release();
- //7 获取当前配置文件路径,输入char*要空间足够,内部没有检测是否越界
- GCV_API void cv_get_conf_file(char*);
- //8 保存到本地配置文件中(覆盖)
- GCV_API void cv_save_param(char* conf_file/*=0*/);
- //9 获取当前的配置参数
- GCV_API void cv_get_param(ConfigParam&);
- //10 获取当前版本号,char*要空间足够,内部没有检测是否越界
- GCV_API void get_version(char* buf);
- //11 茄科上苗,找到抓取位置
- //
- // 输入: points --- 输入, 指向点云的指针,点云为3值一组,结构:[pt0.x, pt0.y, pt0.z, pt1.x, pt1.y,pt1.z], 有时是4值一组(视采集设备数据情况)
- // pixel_size --- 输入,一个点云的维度(一般3或4)
- // pt_size-------- 输入, 点云数量,上例中数量为2
- // dtype -------- 输入,穗苗--0, 砧木--1
- //
- // posinfo ------- 输出
- // fn ------------ 输入, points指向0,且fn可用时,读取文件中的数据(用于测试),仅支持ply格式
- // posinfo.rs_pre_x;
- // posinfo.rs_pre_y;
- // posinfo.rs_pre_z;
- // 其余数据为0
- // 返回: 0- 正常; 其他- 失败
- GCV_API int sola_grab_point_rs(float* points, int pixel_size, int pt_size, PositionInfo& posinfo, const char* fn=0);
- GCV_API int sola_grab_point_sc(float* points, int pixel_size, int pt_size, PositionInfo& posinfo, const char* fn = 0);
- GCV_API int chessboard_calibration(float* points, int pixel_size, int pt_size, PositionInfo& posinfo, const char* fn = 0);
- //12 砧木最优角度识别,追加图像,要求图像的角度按顺序,第一帧图像角度为0,最后一帧图像角度为180
- // 每次追加图片,通过posinfo返回:
- // 1)叶展宽度posinfo.rs_oa_width;
- // 2) 基质宽度posinfo.rs_oa_width_base
- // 3) 茎分叉点y posinfo.rs_oa_stem_y_fork;//茎分叉点y,毫米
- // 4) 茎可视下端y posinfo.rs_oa_clamp_y_end;//茎可视下端y,毫米
- // 5)2帧图像:posinfo.pp_images[0]--砧木分割二值图像 (return image 为 true时)
- // posinfo.pp_images[1]--基质分割二值图像
- // 返回: 0- 正常; 1- 失败
- //GCV_API int rs_oa_append(ImgInfo*, PositionInfo& posinfo);
- //13 获取砧木最优角度
- // ImgInfo* 为输出顶部拍照的图片
- // 返回posinfo.rs_oa, 需要旋转的角度,逆时针为正方向
- // 返回: 0- 正常; 1- 失败
- GCV_API int rs_oa_get_result(ImgInfo*, PositionInfo& posinfo);
- //14 砧木切割点识别,返回
- // posinfo.rs_img_id
- // posinfo.rs_cut_upoint_x
- // posinfo.rs_cut_upoint_y
- // posinfo.rs_stem_diameter
- // posinfo.rs_cut_lpoint_x
- // posinfo.rs_cut_lpoint_y
- // posinfo.pp_images (return image 为 true时)
- // 返回3张图片:图0:二值图像,含茎x-range,茎分叉点右侧边缘坐标(circle中心)
- // 图1: 灰度图,候选角点(circle),候选框,参考点(茎分叉点右侧边缘坐标)
- // 图2:灰度图,上切割点,候选框,参考点,下切点(circle中心),根点(circle中心)
- // 返回: 0- 正常; 1- 失败
- GCV_API int rs_cut_point(ImgInfo*, PositionInfo& posinfo);
- //15 砧木切割点切后识别,返回
- // posinfo.rs_becut_upoint_x
- // posinfo.rs_becut_upoint_y
- // posinfo.pp_images (return image 为 true时)
- // 返回1张图片:图0:二值图像,含茎x-range,上切点(circle中心),下切点(circle中心),根点(circle中心)
- //
- // 返回: 0- 正常; 1- 失败
- GCV_API int rs_cut_point_reid(ImgInfo*, const char* pre_img_id, PositionInfo& posinfo);
- //16 茄科切割点切后识别
- // input:
- // ImgInfo* --- 输入图像
- // sola_type --- 0---穗苗; 1--砧木
- // posinfo---- 返回信息
- //
- // 返回
- // 上切点,中切点,下切点
- // //砧木,坐标左下角位0点
- // posinfo.rs_reid_sola_upoint_x; //base_y, 夹爪基面的y像素坐标, 砧木在下方(夹爪的上沿),接穗在上方(夹爪的下沿)
- // posinfo.rs_reid_sola_upoint_y; //上切割点y像素坐标与base_y的像素距离
- // posinfo.rs_reid_sola_cpoint_x; //--------------------无意义(目标框x)
- // posinfo.rs_reid_sola_cpoint_y; //中切割点y像素坐标与base_y的像素距离
- // posinfo.rs_reid_sola_lpoint_x; //--------------------无意义(目标框x)
- // posinfo.rs_reid_sola_lpoint_y; //下切割点y像素坐标与base_y的像素距离
- //
- // //接穗,坐标左上角位0点
- // posinfo.sc_reid_sola_upoint_x; //base_y, 夹爪基面的y像素坐标, 砧木在下方(夹爪的上沿),接穗在上方(夹爪的下沿)
- // posinfo.sc_reid_sola_upoint_y; //上切割点y像素坐标与base_y的像素距离
- // posinfo.sc_reid_sola_cpoint_x; //--------------------无意义(目标框x)
- // posinfo.sc_reid_sola_cpoint_y; //中切割点y像素坐标与base_y的像素距离
- // posinfo.sc_reid_sola_lpoint_x; //--------------------无意义(目标框x)
- // posinfo.sc_reid_sola_lpoint_y; //下切割点y像素坐标与base_y的像素距离
- //
- // posinfo.pp_images (return image 为 true时)
- // 返回2张图片:图0:二值图像
- // 图1: 灰度图像,拟合椭圆
- //
- // 返回: 0- 正常; 1- 失败
- GCV_API int sola_cut_point_reid_rs(ImgInfo*, PositionInfo& posinfo);
- GCV_API int sola_cut_point_reid_sc(ImgInfo*, PositionInfo& posinfo);
- //17 穗苗上切割点识别,返回
- // posinfo.sc_cut_upoint_x;
- // posinfo.sc_cut_upoint_y;
- // posinfo.sc_cut_cpoint_x;
- // posinfo.sc_cut_cpoint_y;
- // posinfo.pp_images (return image 为 true时)
- // 返回1张图片:图0:二值图像,含茎x-range,茎分叉点水平线,尖点水平线,上切点(circle中心),中切点(circle中心)
- //
- // 返回: 0- 正常; 1- 失败
- GCV_API int sc_cut_point(ImgInfo*, PositionInfo& posinfo);
- };//namespace graft_cv
- #ifdef __cplusplus
- }
- #endif
|