| 44 | |
| 45 | template<typename T> |
| 46 | cv::Rect_<T> fixRatio(cv::Rect_<T> rect, double ratio, bool extend) { |
| 47 | normalize(rect); |
| 48 | double curRatio = rect.height / (double)rect.width; |
| 49 | cv::Rect_<T> fixed = rect; |
| 50 | if ((curRatio < ratio) == extend) { |
| 51 | fixed.height = static_cast<T>(rect.width * ratio); |
| 52 | fixed.y -= (fixed.height - rect.height) / 2; |
| 53 | } |
| 54 | else { |
| 55 | fixed.width = static_cast<T>(rect.height / ratio); |
| 56 | fixed.x -= (fixed.width - rect.width) / 2; |
| 57 | } |
| 58 | return fixed; |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | } |
nothing calls this directly
no test coverage detected