YoloCrowdAPI.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "DetectorAPI.h"
  2. #include "YoloCrowdDetector.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::yolocrowd::YoloCrowdDetector("YoloCrowd", "人头目标检测");
  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 = "YoloCrowd";
  24. info.Name = "人头目标检测";
  25. info.Version = "V1.0.0-T-20241007R";
  26. info.Author = "杭州晨鹰军泰";
  27. info.UpdateDate = "2024-10-07 09:30:00";
  28. info.InputType = masd::EN_BUFFER_TYPE::MRT_BGR;
  29. masd::DetectCfg paramInfo(masd::DIT_FORM, "target", "检测目标类型", "人头", "NAN", "NAN", "NAN", {"head"});
  30. info.ParamTemp = paramInfo.toJson();
  31. masd::yolocrowd::YoloCrowdDetectResult rstInfo;
  32. masd::yolocrowd::DetObj objs;
  33. rstInfo.objs.push_back(objs);
  34. info.RstTemp = rstInfo.toJson();
  35. std::vector<masd::DetectCfg> buildInfos;
  36. buildInfos.emplace_back(masd::DIT_INT, "gpu_id", "GPU ID", "0", "0", "0", "0");
  37. buildInfos.emplace_back(masd::DIT_INT, "max_objects", "检测结果数量上限", "1024", "1", "4096", "1");
  38. buildInfos.emplace_back(masd::DIT_DOUBLE, "confidence_threshold", "全局置信度下限阈值", "0.05", "0.0", "1.0", "0.01");
  39. buildInfos.emplace_back(masd::DIT_DOUBLE, "nms_threshold", "NMS阈值", "0.45", "0.0", "1.0", "0.01");
  40. buildInfos.emplace_back(masd::DIT_STRING, "model_path", "YOLO模型路径", PROGRAM_ROOT_PATH "models/yolo-crowd.trt", "NAN", "NAN", "NAN");
  41. info.BuildTemp = tzc::json::ArrayToJson(buildInfos);
  42. info.AreaTemp = "[focus, ignore]";
  43. info.InitParam = "{\"gpu_id\": 0, \"max_objects\": 1024, \"confidence_threshold\": 0.05, \"nms_threshold\": 0.45, \"model_path\": \"" PROGRAM_ROOT_PATH "models/yolo-crowd.trt\"}";
  44. strcpy(information, info.toJson().c_str());
  45. return masd::MEC_OK;
  46. }