MCPcopy Create free account
hub / github.com/Profactor/cv-plot / fixRatio

Function fixRatio

CvPlot/inc/CvPlot/Internal/util.h:46–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45template<typename T>
46cv::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}

Callers

nothing calls this directly

Calls 1

normalizeFunction · 0.85

Tested by

no test coverage detected