AbandObjAPI.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "DetectorAPI.h"
  2. #include "AbandObjDetector.h"
  3. SDKAPI TZ_INT Initialize()
  4. {
  5. return masd::MEC_OK;
  6. }
  7. SDKAPI TZ_INT Dispose()
  8. {
  9. return masd::MEC_OK;
  10. }
  11. SDKAPI masd::Detector* BuildDetector()
  12. {
  13. masd::Detector* det = new masd::abandobj::AbandObjDetector("AbandObj", "遗留物检测");
  14. return det;
  15. }
  16. SDKAPI void DestroyDetector(masd::Detector* detector)
  17. {
  18. TZ_delete(detector);
  19. }
  20. SDKAPI TZ_INT GetInformation(TZ_CHAR* information)
  21. {
  22. masd::DetectorInfo info;
  23. info.Key = "AbandObj";
  24. info.Name = "遗留物检测";
  25. info.Version = "V1.0.0-T-20241214R";
  26. info.Author = "杭州晨鹰军泰";
  27. info.UpdateDate = "2024-12-14 09:30:00";
  28. info.InputType = masd::EN_BUFFER_TYPE::MRT_BGR;
  29. std::vector<masd::DetectCfg> paramInfos;
  30. paramInfos.emplace_back(masd::DIT_STRING,
  31. "algo", "算法类型", "MOG", "NAN", "NAN", "NAN");
  32. paramInfos.emplace_back(masd::DIT_INT,
  33. "factor", "下采样因子", "4", "1", "16", "1");
  34. paramInfos.emplace_back(masd::DIT_DOUBLE,
  35. "short_term_rate", "短期学习率", "0.01", "0.0001", "1.0", "0.0001");
  36. paramInfos.emplace_back(masd::DIT_INT,
  37. "short_term_history", "短期历史帧数", "200", "10", "1000", "10");
  38. paramInfos.emplace_back(masd::DIT_DOUBLE,
  39. "long_term_rate", "长期学习率", "0.0005", "0.00001", "0.1", "0.00001");
  40. paramInfos.emplace_back(masd::DIT_INT,
  41. "long_term_history", "长期历史帧数", "5000", "100", "20000", "100");
  42. paramInfos.emplace_back(masd::DIT_DOUBLE,
  43. "var_threshold", "阈值变化量", "16.0", "0.1", "100.0", "0.1");
  44. paramInfos.emplace_back(masd::DIT_BOOL,
  45. "detect_shadows", "是否检测阴影", "TRUE", "FALSE", "TRUE", "NAN");
  46. paramInfos.emplace_back(masd::DIT_DOUBLE,
  47. "iou_threshold", "IOU阈值", "0.6", "0.1", "1.0", "0.01");
  48. paramInfos.emplace_back(masd::DIT_DOUBLE,
  49. "area_threshold", "面积阈值", "625.0", "1.0", "10000.0", "1.0");
  50. paramInfos.emplace_back(masd::DIT_DOUBLE,
  51. "perimeter_threshold", "周长阈值", "100.0", "1.0", "1000.0", "1.0");
  52. paramInfos.emplace_back(masd::DIT_DOUBLE,
  53. "confidence_threshold", "关键点置信度阈值", "0.05", "0.0", "1.0", "0.01");
  54. paramInfos.emplace_back(masd::DIT_INT,
  55. "valid_cnt", "可信关键点数量阈值", "7", "0", "14", "1");
  56. info.ParamTemp = tzc::json::ArrayToJson(paramInfos);
  57. masd::abandobj::AbandObjDetectResult rstInfo;
  58. masd::abandobj::Proposal props;
  59. rstInfo.proposals.push_back(props);
  60. info.RstTemp = rstInfo.toJson();
  61. std::vector<masd::DetectCfg> buildInfos;
  62. buildInfos.emplace_back(masd::DIT_STRING, "algo", "算法类型", "MOG2", "NAN", "NAN", "NAN");
  63. buildInfos.emplace_back(masd::DIT_INT, "factor", "下采样因子", "4", "1", "16", "1");
  64. buildInfos.emplace_back(masd::DIT_DOUBLE, "short_term_rate", "短期学习率", "0.01", "0.0001", "1.0", "0.0001");
  65. buildInfos.emplace_back(masd::DIT_INT, "short_term_history", "短期历史帧数", "200", "10", "1000", "10");
  66. buildInfos.emplace_back(masd::DIT_DOUBLE, "long_term_rate", "长期学习率", "0.0005", "0.00001", "0.1", "0.00001");
  67. buildInfos.emplace_back(masd::DIT_INT, "long_term_history", "长期历史帧数", "5000", "100", "20000", "100");
  68. buildInfos.emplace_back(masd::DIT_DOUBLE, "var_threshold", "阈值变化量", "16.0", "0.1", "100.0", "0.1");
  69. buildInfos.emplace_back(masd::DIT_BOOL, "detect_shadows", "是否检测阴影", "TRUE", "FALSE", "TRUE", "NAN");
  70. buildInfos.emplace_back(masd::DIT_DOUBLE, "iou_threshold", "IOU阈值", "0.6", "0.1", "1.0", "0.01");
  71. buildInfos.emplace_back(masd::DIT_DOUBLE, "area_threshold", "面积阈值", "625.0", "1.0", "10000.0", "1.0");
  72. buildInfos.emplace_back(masd::DIT_DOUBLE, "perimeter_threshold", "周长阈值", "100.0", "1.0", "1000.0", "1.0");
  73. info.BuildTemp = tzc::json::ArrayToJson(buildInfos);
  74. info.AreaTemp = "[focus, ignore]";
  75. info.InitParam = "{\"algo\": \"MOG2\", "
  76. "\"factor\": 4, "
  77. "\"short_term_rate\": 0.01, "
  78. "\"short_term_history\": 200, "
  79. "\"long_term_rate\": 0.0005, "
  80. "\"long_term_history\": 5000, "
  81. "\"var_threshold\": 16.0, "
  82. "\"detect_shadows\": true, "
  83. "\"iou_threshold\": 0.6, "
  84. "\"area_threshold\": 625.0, "
  85. "\"perimeter_threshold\": 100.0}";
  86. strcpy(information, info.toJson().c_str());
  87. return masd::MEC_OK;
  88. }