#include "config.h" #include #define VNAME(value) (#value) namespace graft_cv{ CGCvConfig::CGCvConfig() :m_cparam(0) { }; CGCvConfig::~CGCvConfig() { }; void CGCvConfig::setConfParam(ConfigParam*cp) { m_cparam = cp; } void CGCvConfig::write(cv::FileStorage &fs)const{ assert(m_cparam!=0); fs << "{" << "image_show"<< m_cparam->image_show << "image_return"<< m_cparam->image_return << "image_row_grid"<< m_cparam->image_row_grid << "image_col_grid"<< m_cparam->image_col_grid << "self_camera"<< m_cparam->self_camera <<"timeout_proc"<timeout_proc <<"timeout_append"<timeout_append <<"image_save"<image_save <<"image_depository"<image_depository <<"image_backup_days"<image_backup_days << "oa_y_flip"<< m_cparam->oa_y_flip << "oa_morph_radius"<< m_cparam->oa_morph_radius << "oa_morph_iteration" << m_cparam->oa_morph_iteration << "oa_min_leaf_area"<< m_cparam->oa_min_leaf_area << "rs_y_flip"<< m_cparam->rs_y_flip << "rs_min_hist_value"<< m_cparam->rs_min_hist_value << "rs_col_th_ratio" << m_cparam->rs_col_th_ratio << "rs_row_th_ratio" << m_cparam->rs_row_th_ratio << "rs_stem_x_padding" << m_cparam->rs_stem_x_padding << "rs_stem_dia_min" << m_cparam->rs_stem_dia_min << "rs_stem_dia_mp" << m_cparam->rs_stem_dia_mp << "rs_stem_fork_y_min" << m_cparam->rs_stem_fork_y_min << "rs_stem_edge_detect_window" << m_cparam->rs_stem_edge_detect_window << "rs_cand_corner_box_width_ratio" << m_cparam->rs_cand_corner_box_width_ratio << "rs_cand_corner_box_xoffset_ratio" << m_cparam->rs_cand_corner_box_xoffset_ratio << "rs_opt_corner_xoffset_ratio" << m_cparam->rs_opt_corner_xoffset_ratio << "rs_opt_corner_yoffset_ratio" << m_cparam->rs_opt_corner_yoffset_ratio <<"rs_corner_mask_rad_ratio"<rs_corner_mask_rad_ratio << "rs_morph_radius" << m_cparam->rs_morph_radius << "rs_morph_iteration" << m_cparam->rs_morph_iteration << "rs_morph_iteration_gray" << m_cparam->rs_morph_iteration_gray << "rs_max_corner_num" << m_cparam->rs_max_corner_num << "rs_corner_qaulity_level" << m_cparam->rs_corner_qaulity_level << "rs_corner_min_distance" << m_cparam->rs_corner_min_distance << "rs_cut_angle" << m_cparam->rs_cut_angle << "rs_cut_point_offset_ratio"<< m_cparam->rs_cut_point_offset_ratio << "sc_y_flip"<< m_cparam->sc_y_flip << "sc_col_th_ratio" << m_cparam->sc_col_th_ratio << "sc_row_th_ratio" << m_cparam->sc_row_th_ratio << "sc_stem_x_padding" << m_cparam->sc_stem_x_padding << "sc_stem_dia_min"<< m_cparam->sc_stem_dia_min << "sc_clip_padding" << m_cparam->sc_clip_padding << "sc_stem_ymax_padding" << m_cparam->sc_stem_ymax_padding << "sc_default_cut_length" << m_cparam->sc_default_cut_length << "sc_stem_edge_detect_window" << m_cparam->sc_stem_edge_detect_window << "sc_r2_th" << m_cparam->sc_r2_th << "sc_r2_window" << m_cparam->sc_r2_window << "sc_average_window" << m_cparam->sc_average_window << "sc_morph_radius" << m_cparam->sc_morph_radius << "sc_morph_iteration" << m_cparam->sc_morph_iteration << "rs_oa_pixel_ratio" << m_cparam->rs_oa_pixel_ratio << "rs_cut_pixel_ratio" << m_cparam->rs_cut_pixel_ratio << "sc_cut_pixel_ratio" << m_cparam->sc_cut_pixel_ratio << "rs_grab_xmin" << m_cparam->rs_grab_xmin << "rs_grab_xmax" << m_cparam->rs_grab_xmax << "rs_grab_ymin" << m_cparam->rs_grab_ymin << "rs_grab_ymax" << m_cparam->rs_grab_ymax << "rs_grab_zmin" << m_cparam->rs_grab_zmin << "rs_grab_zmax" << m_cparam->rs_grab_zmax << "rs_grab_stem_diameter" << m_cparam->rs_grab_stem_diameter << "rs_grab_y_opt" << m_cparam->rs_grab_y_opt << "rs_grab_seedling_dist" << m_cparam->rs_grab_seedling_dist << "rs_grab_stem_min_pts" << m_cparam->rs_grab_stem_min_pts << "rs_grab_ror_ratio" << m_cparam->rs_grab_ror_ratio << "rs_grab_offset" << m_cparam->rs_grab_offset << "rs_grab_fork_th" << m_cparam->rs_grab_fork_th << "sc_grab_xmin" << m_cparam->sc_grab_xmin << "sc_grab_xmax" << m_cparam->sc_grab_xmax << "sc_grab_ymin" << m_cparam->sc_grab_ymin << "sc_grab_ymax" << m_cparam->sc_grab_ymax << "sc_grab_zmin" << m_cparam->sc_grab_zmin << "sc_grab_zmax" << m_cparam->sc_grab_zmax << "sc_grab_stem_diameter" << m_cparam->sc_grab_stem_diameter << "sc_grab_y_opt" << m_cparam->sc_grab_y_opt << "sc_grab_seedling_dist" << m_cparam->sc_grab_seedling_dist << "sc_grab_stem_min_pts" << m_cparam->sc_grab_stem_min_pts << "sc_grab_ror_ratio" << m_cparam->sc_grab_ror_ratio << "sc_grab_offset" << m_cparam->sc_grab_offset << "sc_grab_fork_th" << m_cparam->sc_grab_fork_th << "}"; }; void CGCvConfig::read(const cv::FileNode& node){ //Read serialization for this class assert(m_cparam!=0); m_cparam->image_show = (bool)(int)node["image_show"]; m_cparam->image_return = (bool)(int)node["image_return"]; m_cparam->image_row_grid = (int)node["image_row_grid"]; m_cparam->image_col_grid = (int)node["image_col_grid"]; m_cparam->self_camera = (bool)(int)node["self_camera"]; m_cparam->timeout_proc = (int)node["timeout_proc"]; m_cparam->timeout_append = (int)node["timeout_append"]; m_cparam->image_save = (bool)(int)node["image_save"]; m_cparam->image_depository =(string)node["image_depository"]; m_cparam->image_backup_days = (int)node["image_backup_days"]; m_cparam->oa_y_flip = (bool)(int)node["oa_y_flip"]; /*m_cparam->rs_min_hist_value = (int)node["rs_min_hist_value"];*/ m_cparam->oa_morph_radius = (int)node["oa_morph_radius"]; m_cparam->oa_morph_iteration = (int)node["oa_morph_iteration"]; m_cparam->oa_min_leaf_area = (int)node["oa_min_leaf_area"]; m_cparam->rs_y_flip = (bool)(int)node["rs_y_flip"]; m_cparam->rs_col_th_ratio = (double)node["rs_col_th_ratio"]; m_cparam->rs_row_th_ratio = (double)node["rs_row_th_ratio"]; m_cparam->rs_stem_x_padding = (int)node["rs_stem_x_padding"]; m_cparam->rs_stem_dia_min = (int)node["rs_stem_dia_min"]; m_cparam->rs_stem_dia_mp = (double)node["rs_stem_dia_mp"]; m_cparam->rs_stem_fork_y_min = (int)node["rs_stem_fork_y_min"]; m_cparam->rs_stem_edge_detect_window = (int)node["rs_stem_edge_detect_window"]; m_cparam->rs_cand_corner_box_width_ratio = (double)node["rs_cand_corner_box_width_ratio"]; m_cparam->rs_cand_corner_box_xoffset_ratio = (double)node["rs_cand_corner_box_xoffset_ratio"]; m_cparam->rs_opt_corner_xoffset_ratio = (double)node["rs_opt_corner_xoffset_ratio"]; m_cparam->rs_opt_corner_yoffset_ratio = (double)node["rs_opt_corner_yoffset_ratio"]; m_cparam->rs_corner_mask_rad_ratio = (double)node["rs_corner_mask_rad_ratio"]; m_cparam->rs_morph_radius = (int)node["rs_morph_radius"]; m_cparam->rs_morph_iteration = (int)node["rs_morph_iteration"]; m_cparam->rs_morph_iteration_gray = (int)node["rs_morph_iteration_gray"]; m_cparam->rs_max_corner_num = (int)node["rs_max_corner_num"]; m_cparam->rs_corner_qaulity_level = (double)node["rs_corner_qaulity_level"]; m_cparam->rs_corner_min_distance = (double)node["rs_corner_min_distance"]; m_cparam->rs_cut_angle = (double)node["rs_cut_angle"]; m_cparam->rs_cut_point_offset_ratio = (double)node["rs_cut_point_offset_ratio"]; m_cparam->sc_y_flip = (bool)(int)node["sc_y_flip"]; m_cparam->sc_col_th_ratio = (double)node["sc_col_th_ratio"]; m_cparam->sc_row_th_ratio = (double)node["sc_row_th_ratio"]; m_cparam->sc_stem_x_padding = (int)node["sc_stem_x_padding"]; m_cparam->sc_stem_dia_min = (int)node["sc_stem_dia_min"]; m_cparam->sc_clip_padding = (int)node["sc_clip_padding"]; m_cparam->sc_stem_ymax_padding = (int)node["sc_stem_ymax_padding"]; m_cparam->sc_default_cut_length = (int)node["sc_default_cut_length"]; m_cparam->sc_stem_edge_detect_window = (int)node["sc_stem_edge_detect_window"]; m_cparam->sc_r2_th = (double)node["sc_r2_th"]; m_cparam->sc_r2_window = (int)node["sc_r2_window"]; m_cparam->sc_average_window = (int)node["sc_average_window"]; m_cparam->sc_morph_radius = (int)node["sc_morph_radius"]; m_cparam->sc_morph_iteration = (int)node["sc_morph_iteration"]; m_cparam->rs_oa_pixel_ratio = (double)node["rs_oa_pixel_ratio"]; m_cparam->rs_cut_pixel_ratio = (double)node["rs_cut_pixel_ratio"]; m_cparam->sc_cut_pixel_ratio = (double)node["sc_cut_pixel_ratio"]; m_cparam->rs_grab_xmin = (double)node["rs_grab_xmin"]; m_cparam->rs_grab_xmax = (double)node["rs_grab_xmax"]; m_cparam->rs_grab_ymin = (double)node["rs_grab_ymin"]; m_cparam->rs_grab_ymax = (double)node["rs_grab_ymax"]; m_cparam->rs_grab_zmin = (double)node["rs_grab_zmin"]; m_cparam->rs_grab_zmax = (double)node["rs_grab_zmax"]; m_cparam->rs_grab_stem_diameter = (double)node["rs_grab_stem_diameter"]; m_cparam->rs_grab_y_opt = (double)node["rs_grab_y_opt"]; m_cparam->rs_grab_seedling_dist = (double)node["rs_grab_seedling_dist"]; m_cparam->rs_grab_stem_min_pts = (int)node["rs_grab_stem_min_pts"]; m_cparam->rs_grab_ror_ratio = (double)node["rs_grab_ror_ratio"]; m_cparam->rs_grab_offset = (double)node["rs_grab_offset"]; m_cparam->rs_grab_fork_th = (double)node["rs_grab_fork_th"]; m_cparam->sc_grab_xmin = (double)node["sc_grab_xmin"]; m_cparam->sc_grab_xmax = (double)node["sc_grab_xmax"]; m_cparam->sc_grab_ymin = (double)node["sc_grab_ymin"]; m_cparam->sc_grab_ymax = (double)node["sc_grab_ymax"]; m_cparam->sc_grab_zmin = (double)node["sc_grab_zmin"]; m_cparam->sc_grab_zmax = (double)node["sc_grab_zmax"]; m_cparam->sc_grab_stem_diameter = (double)node["sc_grab_stem_diameter"]; m_cparam->sc_grab_y_opt = (double)node["sc_grab_y_opt"]; m_cparam->sc_grab_seedling_dist = (double)node["sc_grab_seedling_dist"]; m_cparam->sc_grab_stem_min_pts = (int)node["sc_grab_stem_min_pts"]; m_cparam->sc_grab_ror_ratio = (double)node["sc_grab_ror_ratio"]; m_cparam->sc_grab_offset = (double)node["sc_grab_offset"]; m_cparam->sc_grab_fork_th = (double)node["sc_grab_fork_th"]; } string get_cparam_info(ConfigParam*m_cparam) { if(!m_cparam){return string("");} stringstream buff; buff << "{" <image_show << endl << "image_return:\t"<< m_cparam->image_return << endl << "image_row_grid:\t"<< m_cparam->image_row_grid << endl << "image_col_grid:\t"<< m_cparam->image_col_grid << endl << "self_camera:\t"<< m_cparam->self_camera << endl <<"timeout_proc:\t"<timeout_proc << endl <<"timeout_append:\t"<timeout_append << endl <<"image_save:\t"<image_save << endl <<"image_depository:\t"<image_depository << endl <<"image_backup_days:\t"<image_backup_days << endl << "oa_y_flip:\t"<< m_cparam->oa_y_flip << endl << "oa_morph_radius:\t"<< m_cparam->oa_morph_radius << endl << "oa_morph_iteration:\t" << m_cparam->oa_morph_iteration << endl << "oa_min_leaf_area:\t"<< m_cparam->oa_min_leaf_area << endl << "rs_y_flip:\t"<< m_cparam->rs_y_flip << endl << "rs_min_hist_value:\t"<< m_cparam->rs_min_hist_value << endl << "rs_col_th_ratio:\t" << m_cparam->rs_col_th_ratio << endl << "rs_row_th_ratio:\t" << m_cparam->rs_row_th_ratio << endl << "rs_stem_x_padding:\t" << m_cparam->rs_stem_x_padding << endl << "rs_stem_dia_min:\t" << m_cparam->rs_stem_dia_min << endl << "rs_stem_dia_mp:\t" << m_cparam->rs_stem_dia_mp << endl << "rs_stem_fork_y_min:\t" << m_cparam->rs_stem_fork_y_min << endl << "rs_stem_edge_detect_window:\t" << m_cparam->rs_stem_edge_detect_window << endl << "rs_cand_corner_box_width_ratio:\t" << m_cparam->rs_cand_corner_box_width_ratio << endl << "rs_cand_corner_box_xoffset_ratio:\t" << m_cparam->rs_cand_corner_box_xoffset_ratio << endl << "rs_opt_corner_xoffset_ratio:\t" << m_cparam->rs_opt_corner_xoffset_ratio << endl << "rs_opt_corner_yoffset_ratio:\t" << m_cparam->rs_opt_corner_yoffset_ratio << endl <<"rs_corner_mask_rad_ratio:\t"<rs_corner_mask_rad_ratio << endl << "rs_morph_radius:\t" << m_cparam->rs_morph_radius << endl << "rs_morph_iteration:\t" << m_cparam->rs_morph_iteration << endl << "rs_morph_iteration_gray:\t" << m_cparam->rs_morph_iteration_gray << endl << "rs_max_corner_num:\t" << m_cparam->rs_max_corner_num << endl << "rs_corner_qaulity_level:\t" << m_cparam->rs_corner_qaulity_level << endl << "rs_corner_min_distance:\t" << m_cparam->rs_corner_min_distance << endl << "rs_cut_angle:\t" << m_cparam->rs_cut_angle << endl << "rs_cut_point_offset_ratio:\t"<< m_cparam->rs_cut_point_offset_ratio << endl << "sc_y_flip:\t"<< m_cparam->sc_y_flip << endl << "sc_col_th_ratio:\t" << m_cparam->sc_col_th_ratio << endl << "sc_row_th_ratio:\t" << m_cparam->sc_row_th_ratio << endl << "sc_stem_x_padding:\t" << m_cparam->sc_stem_x_padding << endl << "sc_stem_dia_min:\t"<< m_cparam->sc_stem_dia_min << endl << "sc_clip_padding:\t" << m_cparam->sc_clip_padding << endl << "sc_stem_ymax_padding:\t" << m_cparam->sc_stem_ymax_padding << endl << "sc_default_cut_length:\t" << m_cparam->sc_default_cut_length << endl << "sc_stem_edge_detect_window:\t" << m_cparam->sc_stem_edge_detect_window << endl << "sc_r2_th:\t" << m_cparam->sc_r2_th << endl << "sc_r2_window:\t" << m_cparam->sc_r2_window << endl << "sc_average_window:\t" << m_cparam->sc_average_window << endl << "sc_morph_radius:\t" << m_cparam->sc_morph_radius << endl << "sc_morph_iteration:\t" << m_cparam->sc_morph_iteration << endl << "rs_oa_pixel_ratio:\t" << m_cparam->rs_oa_pixel_ratio << endl << "rs_cut_pixel_ratio:\t" << m_cparam->rs_cut_pixel_ratio << endl << "sc_cut_pixel_ratio:\t" << m_cparam->sc_cut_pixel_ratio << endl << "rs_grab_xmin:\t" << m_cparam->rs_grab_xmin << endl << "rs_grab_xmax:\t" << m_cparam->rs_grab_xmax << endl << "rs_grab_ymin:\t" << m_cparam->rs_grab_ymin << endl << "rs_grab_ymax:\t" << m_cparam->rs_grab_ymax << endl << "rs_grab_zmin:\t" << m_cparam->rs_grab_zmin << endl << "rs_grab_zmax:\t" << m_cparam->rs_grab_zmax << endl << "rs_grab_stem_diameter:\t" << m_cparam->rs_grab_stem_diameter << endl << "rs_grab_y_opt:\t" << m_cparam->rs_grab_y_opt << endl << "rs_grab_seedling_dist:\t" << m_cparam->rs_grab_seedling_dist << endl << "rs_grab_stem_min_pts:\t" << m_cparam->rs_grab_stem_min_pts << endl << "rs_grab_ror_ratio:\t" << m_cparam->rs_grab_ror_ratio << endl << "rs_grab_offset:\t" << m_cparam->rs_grab_offset << endl << "rs_grab_fork_th:\t" << m_cparam->rs_grab_fork_th << endl << "sc_grab_xmin:\t" << m_cparam->sc_grab_xmin << endl << "sc_grab_xmax:\t" << m_cparam->sc_grab_xmax << endl << "sc_grab_ymin:\t" << m_cparam->sc_grab_ymin << endl << "sc_grab_ymax:\t" << m_cparam->sc_grab_ymax << endl << "sc_grab_zmin:\t" << m_cparam->sc_grab_zmin << endl << "sc_grab_zmax:\t" << m_cparam->sc_grab_zmax << endl << "sc_grab_stem_diameter:\t" << m_cparam->sc_grab_stem_diameter << endl << "sc_grab_y_opt:\t" << m_cparam->sc_grab_y_opt << endl << "sc_grab_seedling_dist:\t" << m_cparam->sc_grab_seedling_dist << endl << "sc_grab_stem_min_pts:\t" << m_cparam->sc_grab_stem_min_pts << endl << "sc_grab_ror_ratio:\t" << m_cparam->sc_grab_ror_ratio << endl << "sc_grab_offset:\t" << m_cparam->sc_grab_offset << endl << "sc_grab_fork_th:\t" << m_cparam->sc_grab_fork_th << endl << "}" << endl; return buff.str(); } }