Commit c210395c authored by Davis King's avatar Davis King

Made chip_details do something more benign when the user gives an empty

rectangle.
parent 2ed128e2
...@@ -1757,6 +1757,12 @@ namespace dlib ...@@ -1757,6 +1757,12 @@ namespace dlib
void compute_dims_from_size ( void compute_dims_from_size (
unsigned long size unsigned long size
) )
{
if (rect.is_empty())
{
cols = rows = std::round(std::sqrt((double)size));
}
else
{ {
const double relative_size = std::sqrt(size/(double)rect.area()); const double relative_size = std::sqrt(size/(double)rect.area());
rows = static_cast<unsigned long>(rect.height()*relative_size + 0.5); rows = static_cast<unsigned long>(rect.height()*relative_size + 0.5);
...@@ -1764,6 +1770,7 @@ namespace dlib ...@@ -1764,6 +1770,7 @@ namespace dlib
rows = std::max(1ul,rows); rows = std::max(1ul,rows);
cols = std::max(1ul,cols); cols = std::max(1ul,cols);
} }
}
}; };
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
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