Commit b56f73ce authored by Davis King's avatar Davis King

Added box_percent_covered()

parent ac5206eb
...@@ -34,6 +34,29 @@ namespace dlib ...@@ -34,6 +34,29 @@ namespace dlib
return box_intersection_over_union(drectangle(a),drectangle(b)); return box_intersection_over_union(drectangle(a),drectangle(b));
} }
// ----------------------------------------------------------------------------------------
inline double box_percent_covered (
const drectangle& a,
const drectangle& b
)
{
const double inner = a.intersect(b).area();
if (inner == 0)
return 0;
return std::max(inner/a.area(), inner/b.area());
}
// ----------------------------------------------------------------------------------------
inline double box_percent_covered (
const rectangle& a,
const rectangle& b
)
{
return box_percent_covered(drectangle(a), drectangle(b));
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
class test_box_overlap class test_box_overlap
......
...@@ -32,6 +32,34 @@ namespace dlib ...@@ -32,6 +32,34 @@ namespace dlib
boxes are empty then returns 0. boxes are empty then returns 0.
!*/ !*/
// ----------------------------------------------------------------------------------------
inline double box_percent_covered (
const drectangle& a,
const drectangle& b
);
/*!
ensures
- let OVERLAP = a.intersect(b).area()
- This function returns max(OVERLAP/a.area(), OVERLAP/b.area())
e.g. If one box entirely contains another then this function returns 1, if
they don't overlap at all it returns 0.
!*/
// ----------------------------------------------------------------------------------------
inline double box_percent_covered (
const rectangle& a,
const rectangle& b
);
/*!
ensures
- let OVERLAP = a.intersect(b).area()
- This function returns max(OVERLAP/a.area(), OVERLAP/b.area())
e.g. If one box entirely contains another then this function returns 1, if
they don't overlap at all it returns 0.
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
class test_box_overlap class test_box_overlap
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment