config.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. << "model_path_cut" << m_cparam->model_path_cut
  28. << "object_threshold_cut" << m_cparam->object_threshold_cut
  29. << "nms_threshold_cut" << m_cparam->nms_threshold_cut
  30. << "}";
  31. };
  32. void CGCvConfig::read(const cv::FileNode& node){ //Read serialization for this class
  33. assert(m_cparam!=0);
  34. m_cparam->image_show = (bool)(int)node["image_show"];
  35. m_cparam->image_return = (bool)(int)node["image_return"];
  36. m_cparam->image_save = (bool)(int)node["image_save"];
  37. m_cparam->image_depository =(string)node["image_depository"];
  38. m_cparam->image_backup_days = (int)node["image_backup_days"];
  39. m_cparam->model_path_grab =(string)node["model_path_grab"];
  40. m_cparam->object_threshold_grab = (float)node["object_threshold_grab"];
  41. m_cparam->nms_threshold_grab = (float)node["nms_threshold_grab"];
  42. m_cparam->model_path_cut = (string)node["model_path_cut"];
  43. m_cparam->object_threshold_cut = (float)node["object_threshold_cut"];
  44. m_cparam->nms_threshold_cut = (float)node["nms_threshold_cut"];
  45. }
  46. string get_cparam_info(ConfigParam*m_cparam)
  47. {
  48. if(!m_cparam){return string("");}
  49. stringstream buff;
  50. buff << "{" <<endl
  51. << "image_show:\t"<< m_cparam->image_show << endl
  52. << "image_return:\t"<< m_cparam->image_return << endl
  53. <<"image_save:\t"<<m_cparam->image_save << endl
  54. <<"image_depository:\t"<<m_cparam->image_depository << endl
  55. <<"image_backup_days:\t"<<m_cparam->image_backup_days << endl
  56. <<"model_path_grab:\t"<<m_cparam->model_path_grab << endl
  57. <<"object_threshold_grab:\t"<<m_cparam->object_threshold_grab << endl
  58. <<"nms_threshold_grab:\t"<<m_cparam->nms_threshold_grab << endl
  59. << "model_path_cut:\t" << m_cparam->model_path_cut << endl
  60. << "object_threshold_cut:\t" << m_cparam->object_threshold_cut << endl
  61. << "nms_threshold_cut:\t" << m_cparam->nms_threshold_cut << endl
  62. << "}" << endl;
  63. return buff.str();
  64. }
  65. }