config.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "config.h"
  2. #include <iostream>
  3. #define VNAME(value) (#value)
  4. namespace graft_cv{
  5. CGCvConfig::CGCvConfig()
  6. :m_cparam(0)
  7. {
  8. };
  9. CGCvConfig::~CGCvConfig()
  10. {
  11. };
  12. void CGCvConfig::setConfParam(ConfigParam*cp)
  13. {
  14. m_cparam = cp;
  15. }
  16. void CGCvConfig::write(cv::FileStorage &fs)const{
  17. assert(m_cparam!=0);
  18. fs << "{"
  19. << "image_show"<< m_cparam->image_show
  20. << "image_return"<< m_cparam->image_return
  21. <<"image_save"<<m_cparam->image_save
  22. <<"image_depository"<<m_cparam->image_depository
  23. <<"image_backup_days"<<m_cparam->image_backup_days
  24. <<"model_path_grab"<<m_cparam->model_path_grab
  25. <<"object_threshold_grab"<<m_cparam->object_threshold_grab
  26. <<"nms_threshold_grab"<<m_cparam->nms_threshold_grab
  27. << "grid_row_grab" << m_cparam->grid_row_grab
  28. << "grid_col_grab" << m_cparam->grid_col_grab
  29. << "grid_padding_grab" << m_cparam->grid_padding_grab
  30. << "offset_grab" << m_cparam->offset_grab
  31. << "model_path_cut" << m_cparam->model_path_cut
  32. << "object_threshold_cut" << m_cparam->object_threshold_cut
  33. << "nms_threshold_cut" << m_cparam->nms_threshold_cut
  34. << "grid_row_cut" << m_cparam->grid_row_cut
  35. << "grid_col_cut" << m_cparam->grid_col_cut
  36. << "grid_padding_cut" << m_cparam->grid_padding_cut
  37. << "}";
  38. };
  39. void CGCvConfig::read(const cv::FileNode& node){ //Read serialization for this class
  40. assert(m_cparam!=0);
  41. m_cparam->image_show = (bool)(int)node["image_show"];
  42. m_cparam->image_return = (bool)(int)node["image_return"];
  43. m_cparam->image_save = (bool)(int)node["image_save"];
  44. m_cparam->image_depository =(string)node["image_depository"];
  45. m_cparam->image_backup_days = (int)node["image_backup_days"];
  46. m_cparam->model_path_grab =(string)node["model_path_grab"];
  47. m_cparam->object_threshold_grab = (float)node["object_threshold_grab"];
  48. m_cparam->nms_threshold_grab = (float)node["nms_threshold_grab"];
  49. m_cparam->grid_row_grab = (int)node["grid_row_grab"];
  50. m_cparam->grid_col_grab = (int)node["grid_col_grab"];
  51. m_cparam->grid_padding_grab = (int)node["grid_padding_grab"];
  52. m_cparam->offset_grab = (int)node["offset_grab"];
  53. m_cparam->model_path_cut = (string)node["model_path_cut"];
  54. m_cparam->object_threshold_cut = (float)node["object_threshold_cut"];
  55. m_cparam->nms_threshold_cut = (float)node["nms_threshold_cut"];
  56. m_cparam->grid_row_cut = (int)node["grid_row_cut"];
  57. m_cparam->grid_col_cut = (int)node["grid_col_cut"];
  58. m_cparam->grid_padding_cut = (int)node["grid_padding_cut"];
  59. }
  60. string get_cparam_info(ConfigParam*m_cparam)
  61. {
  62. if(!m_cparam){return string("");}
  63. stringstream buff;
  64. buff << "{" <<endl
  65. << "image_show:\t"<< m_cparam->image_show << endl
  66. << "image_return:\t"<< m_cparam->image_return << endl
  67. <<"image_save:\t"<<m_cparam->image_save << endl
  68. <<"image_depository:\t"<<m_cparam->image_depository << endl
  69. <<"image_backup_days:\t"<<m_cparam->image_backup_days << endl
  70. <<"model_path_grab:\t"<<m_cparam->model_path_grab << endl
  71. <<"object_threshold_grab:\t"<<m_cparam->object_threshold_grab << endl
  72. <<"nms_threshold_grab:\t"<<m_cparam->nms_threshold_grab << endl
  73. << "grid_row_grab:\t" << m_cparam->grid_row_grab << endl
  74. << "grid_col_grab:\t" << m_cparam->grid_col_grab << endl
  75. << "grid_padding_grab:\t" << m_cparam->grid_padding_grab << endl
  76. << "offset_grab:\t" << m_cparam->offset_grab << endl
  77. << "model_path_cut:\t" << m_cparam->model_path_cut << endl
  78. << "object_threshold_cut:\t" << m_cparam->object_threshold_cut << endl
  79. << "nms_threshold_cut:\t" << m_cparam->nms_threshold_cut << endl
  80. << "grid_row_cut:\t" << m_cparam->grid_row_cut << endl
  81. << "grid_col_cut:\t" << m_cparam->grid_col_cut << endl
  82. << "grid_padding_cut:\t" << m_cparam->grid_padding_cut << endl
  83. << "}" << endl;
  84. return buff.str();
  85. }
  86. }