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
...@@ -1758,11 +1758,18 @@ namespace dlib ...@@ -1758,11 +1758,18 @@ namespace dlib
unsigned long size unsigned long size
) )
{ {
const double relative_size = std::sqrt(size/(double)rect.area()); if (rect.is_empty())
rows = static_cast<unsigned long>(rect.height()*relative_size + 0.5); {
cols = static_cast<unsigned long>(size/(double)rows + 0.5); cols = rows = std::round(std::sqrt((double)size));
rows = std::max(1ul,rows); }
cols = std::max(1ul,cols); else
{
const double relative_size = std::sqrt(size/(double)rect.area());
rows = static_cast<unsigned long>(rect.height()*relative_size + 0.5);
cols = static_cast<unsigned long>(size/(double)rows + 0.5);
rows = std::max(1ul,rows);
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