123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include "DetUtils.h"
- NAMESPACE_MAS_BEGIN
- NAMESPACE_DETUTILS_BEGIN
- TZ_BOOL IsInRoi(const TZ_DOUBLE & ltx, const TZ_DOUBLE & lty,
- const TZ_DOUBLE & rbx, const TZ_DOUBLE & rby,
- const std::vector<AreaBox> & focusArea,
- const std::vector<AreaBox> & ignoreArea,
- const TZ_DOUBLE & roiThreshold)
- {
- if (focusArea.empty() && ignoreArea.empty()) return TRUE;
- TZ_DOUBLE objArea = std::max(rbx - ltx, 0.0)
- * std::max(rby - lty, 0.0);
- if (!focusArea.empty())
- {
- TZ_BOOL ret = FALSE;
- for (auto & area : focusArea)
- {
- TZ_DOUBLE left = std::max(ltx, area.LTX);
- TZ_DOUBLE top = std::max(lty, area.LTY);
- TZ_DOUBLE right = std::min(rbx, area.RBX);
- TZ_DOUBLE bottom = std::min(rby, area.RBY);
- TZ_DOUBLE dupe = std::max(right - left, 0.0)
- * std::max(bottom - top, 0.0);
- if (dupe / objArea >= roiThreshold)
- {
- ret = TRUE;
- break;
- }
- }
- return ret;
- }
- TZ_BOOL ret = TRUE;
- for (auto & area : ignoreArea)
- {
- TZ_DOUBLE left = std::max(ltx, area.LTX);
- TZ_DOUBLE top = std::max(lty, area.LTY);
- TZ_DOUBLE right = std::min(rbx, area.RBX);
- TZ_DOUBLE bottom = std::min(rby, area.RBY);
- TZ_DOUBLE dupe = std::max(right - left, 0.0)
- * std::max(bottom - top, 0.0);
- if (dupe / objArea >= roiThreshold)
- {
- ret = FALSE;
- break;
- }
- }
- return ret;
- }
- TZ_INT GetDetSample(TZ_INT freq)
- {
- std::vector<TZ_INT> gaps {1, 3, 5, 12, 25};
- return gaps[freq];
- }
- NAMESPACE_DETUTILS_END
- NAMESPACE_MAS_END
|