DetUtils.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "DetUtils.h"
  2. NAMESPACE_MAS_BEGIN
  3. NAMESPACE_DETUTILS_BEGIN
  4. TZ_BOOL IsInRoi(const TZ_DOUBLE & ltx, const TZ_DOUBLE & lty,
  5. const TZ_DOUBLE & rbx, const TZ_DOUBLE & rby,
  6. const std::vector<AreaBox> & focusArea,
  7. const std::vector<AreaBox> & ignoreArea,
  8. const TZ_DOUBLE & roiThreshold)
  9. {
  10. if (focusArea.empty() && ignoreArea.empty()) return TRUE;
  11. TZ_DOUBLE objArea = std::max(rbx - ltx, 0.0)
  12. * std::max(rby - lty, 0.0);
  13. if (!focusArea.empty())
  14. {
  15. TZ_BOOL ret = FALSE;
  16. for (auto & area : focusArea)
  17. {
  18. TZ_DOUBLE left = std::max(ltx, area.LTX);
  19. TZ_DOUBLE top = std::max(lty, area.LTY);
  20. TZ_DOUBLE right = std::min(rbx, area.RBX);
  21. TZ_DOUBLE bottom = std::min(rby, area.RBY);
  22. TZ_DOUBLE dupe = std::max(right - left, 0.0)
  23. * std::max(bottom - top, 0.0);
  24. if (dupe / objArea >= roiThreshold)
  25. {
  26. ret = TRUE;
  27. break;
  28. }
  29. }
  30. return ret;
  31. }
  32. TZ_BOOL ret = TRUE;
  33. for (auto & area : ignoreArea)
  34. {
  35. TZ_DOUBLE left = std::max(ltx, area.LTX);
  36. TZ_DOUBLE top = std::max(lty, area.LTY);
  37. TZ_DOUBLE right = std::min(rbx, area.RBX);
  38. TZ_DOUBLE bottom = std::min(rby, area.RBY);
  39. TZ_DOUBLE dupe = std::max(right - left, 0.0)
  40. * std::max(bottom - top, 0.0);
  41. if (dupe / objArea >= roiThreshold)
  42. {
  43. ret = FALSE;
  44. break;
  45. }
  46. }
  47. return ret;
  48. }
  49. TZ_INT GetDetSample(TZ_INT freq)
  50. {
  51. std::vector<TZ_INT> gaps {1, 3, 5, 12, 25};
  52. return gaps[freq];
  53. }
  54. NAMESPACE_DETUTILS_END
  55. NAMESPACE_MAS_END