PerspectiveTransformEngine class
Production-grade perspective transform engine implementing 4-point homography via Direct Linear Transform (DLT) with bilinear interpolation.
Inspired by OpenCV's cv::getPerspectiveTransform() + cv::warpPerspective()
and Scanbot SDK's document perspective correction pipeline.
This engine:
- Computes the 3×3 homography matrix from 4 source → 4 destination point pairs
- Applies inverse mapping with bilinear interpolation for artifact-free warping
- Provides utility methods for coordinate mapping and ROI extraction
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
computeDocumentHomography(
DocumentCorners corners, {required int outputWidth, required int outputHeight}) → Float64List - Computes the homography to warp a detected document quadrilateral to a flat rectangle of specified dimensions.
-
computeHomography(
List< Offset> src, List<Offset> dst) → Float64List - Computes a 3×3 homography matrix mapping 4 source points to 4 destination points using the Direct Linear Transform (DLT) algorithm.
-
homographyToMatrix4(
Float64List h) → Matrix4 - Converts a Float64List homography to a Flutter Matrix4 for use in CustomPainter transforms and widget rendering.
-
transformPoint(
Float64List homography, Offset point) → Offset - Maps a single point through the homography transformation.
-
warpDocument(
Uint8List gray, int srcWidth, int srcHeight, DocumentCorners corners, {int? outputWidth, int? outputHeight}) → PerspectiveWarpResult - Warps a document image from detected quad corners to a flat rectangle.
-
warpPerspective(
Uint8List gray, int srcWidth, int srcHeight, Float64List homography, int dstWidth, int dstHeight, {int backgroundColor = 255}) → Uint8List - Warps a grayscale image using the given homography matrix with bilinear interpolation for sub-pixel accuracy.