From 23b00b9e90bc862105d9ad59328880fda00c1d94 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Mon, 3 Nov 2014 16:54:03 -0500 Subject: [PATCH] Added overlap rect utility --- openbr/core/qtutils.cpp | 6 ++++++ openbr/core/qtutils.h | 3 +++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/openbr/core/qtutils.cpp b/openbr/core/qtutils.cpp index 53ab3c4..c16a20b 100644 --- a/openbr/core/qtutils.cpp +++ b/openbr/core/qtutils.cpp @@ -478,5 +478,11 @@ float euclideanLength(const QPointF &point) return sqrt(pow(point.x(), 2) + pow(point.y(), 2)); } +float overlap(const QRectF &r, const QRectF &s) { + QRectF intersection = r & s; + + return (intersection.width()*intersection.height())/(r.width()*r.height()); +} + } // namespace QtUtils diff --git a/openbr/core/qtutils.h b/openbr/core/qtutils.h index 5c11416..43d7720 100644 --- a/openbr/core/qtutils.h +++ b/openbr/core/qtutils.h @@ -89,6 +89,9 @@ namespace QtUtils /**** Point Utilities ****/ float euclideanLength(const QPointF &point); + + /**** Rect Utilities ****/ + float overlap(const QRectF &r, const QRectF &s); } #endif // QTUTILS_QTUTILS_H -- libgit2 0.21.4