inverseTransformRect method
Transforms a rect
from coordinates system of the result image back to the one of the input
image.
Implementation
Rect inverseTransformRect(
Rect rect, int inputImageHeight, int inputImageWidth) {
// when rotation is involved, corner order may change - top left changes to bottom right, .etc
Point p1 = inverseTransform(
Point(rect.left, rect.top), inputImageHeight, inputImageWidth);
Point p2 = inverseTransform(
Point(rect.right, rect.bottom), inputImageHeight, inputImageWidth);
return Rect.fromLTRB(min(p1.x, p2.x) as double, min(p1.y, p2.y) as double,
max(p1.x, p2.x) as double, max(p1.y, p2.y) as double);
}