#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 & focusArea, const std::vector & 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 gaps {1, 3, 5, 12, 25}; return gaps[freq]; } NAMESPACE_DETUTILS_END NAMESPACE_MAS_END