123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- //cut point recognization for rootstock plant
- #pragma once
- #include <time.h>
- #include <opencv.hpp>
- #include "data_def_api.h"
- #include "data_def.h"
- #include "logger.h"
- #include "imstorage_manager.h"
- using namespace cv;
- namespace graft_cv{
- class CRootStockCutPoint{
- public:
- CRootStockCutPoint(ConfigParam&c,CGcvLogger*pLog=0);
- ~CRootStockCutPoint();
- int up_point_detect(//上切割点,切前识别
- ImgInfo*,
- Mat&,
- PositionInfo& posinfo
- );
- //int up_point_reid( // 上切割点,切后重识别
- // ImgInfo*,
- // Mat&,
- // double edge_length,
- // PositionInfo& posinfo
- // );
- void set_image_saver(CImStoreManager** ppis){m_ppImgSaver=ppis;}
- private:
- Mat m_binImg;// binary image
- Mat m_grayImg;// gray image
- Mat m_edgeImg;
- string m_imgId;
- CImStoreManager** m_ppImgSaver;
- //返回图片,用于调试
- ImgInfo* m_pImginfoBinFork;//fork-y, right-x
- ImgInfo* m_pImgCorners;//corners, reference-point, candidate box
- ImgInfo* m_pImgCutPoint;//reference-point, cutpoint
- //global configure parameters
- ConfigParam& m_cparam;
- CGcvLogger * m_pLogger;
- // image segment
- void img_segment(Mat&);
-
- // get_optimal_corner()
- // return 0--success, 1--error
- int get_optimal_corner(
- int ref_x,
- int ref_y,
- std::vector<Point2f>& corners,
- int stem_dia,
- double cand_corner_box_width_ratio,
- double cand_corner_box_xoffset_ratio,
- double opt_corner_xoffset_ratio,
- double opt_corner_yoffset_ratio,
- double corner_mask_radius_ratio,
- Point2f& cut_pt);
- void get_default_cutpoint(
- int fork_cent_x,
- int fork_cent_y,
- int fork_stem_dia,
- Point2f& cut_pt);
- void clear_imginfo();
- /// pre-cut calculationo
- //# 通过砧木切前切割点识别结果(切割点)、二值图像,茎根y值,刀角度
- //# 输出切割点到根部的边缘曲线长度
- double get_cut_edge_length(
- Mat& bin_img,
- Mat& edge_img,
- gcv_point<int>& start_pt, //up cut point
- gcv_point<int>& lower_cut_pt,//output
- gcv_point<int>& root_pt,//output
- double cut_angle,
- int y_max,
- int stem_dia,
- clock_t t0
- );
- void find_lower_cut_point(
- Mat& bin_img,
- gcv_point<int>&start_pt,
- gcv_point<int>&end_pt,//output
- double cut_angle,
- int stem_dia);
- double calculate_edge_length(
- Mat& edge_img,
- gcv_point<int>&lower_cut_pt,
- gcv_point<int>&root_pt,//output
- int y_max,
- clock_t t0
- );
- //corner evluation
- void corner_magnificence(
- const vector<Point2f>& cand_pts,
- int stem_dia,
- double corner_mask_radius_ratio,
- vector<double>& scores
- );
- //functions for reid
- int get_root_point_reid(
- int x0,
- int x1,
- int stem_end_y,
- bool is_right //是否右侧根部点, true-右侧,false-左侧
- );
- void find_upper_cut_point_reid(
- Mat& edge_img,
- gcv_point<int>&start_pt,
- gcv_point<int>&end_pt,//output
- double curve_length
- );
- void get_stem_root_y(
- vector<int>&hist_row,
- double rs_stem_dia_min,
- int &stem_end_y);
- };
- };
|