UNPKG

document-scanner-vue

Version:

Vue 3 Document Scanner with OpenCV.js - Mobile optimized with camera/gallery support

43 lines 2.87 kB
import { Point, Corners } from '../types'; /** * Sorts corners to ensure consistent order: top-left, top-right, bottom-right, bottom-left * This prevents unexpected rotations/flips when user adjusts corners manually * @param {Point[]} corners - Array of 4 corner points in any order * @returns {Point[]} - Sorted corners in consistent order */ export declare function sortCornersForConsistentOrientation(corners: Point[]): Point[]; /** * Transforms corner coordinates to match a rotated image's coordinate system. * @param {ReadonlyArray<Point>} corners - Original corner coordinates (should be a readonly array of 4 points) * @param {number} rotationAngle - Rotation angle in degrees (90, 180, 270) * @param {number} originalWidth - Width of the original image * @param {number} originalHeight - Height of the original image * @returns {Corners | null} - Transformed corner coordinates for the rotated image as a Corners type, or null if input is invalid. */ export declare function transformCornersForRotation(corners: ReadonlyArray<Point>, rotationAngle: number, originalWidth: number, originalHeight: number): Corners | null; /** * Transforms display corner coordinates (relative to a rotated image) back to base coordinates (relative to 0-degree image). * This is the inverse of transformCornersForRotation. * @param {ReadonlyArray<Point>} displayCorners - Corner coordinates relative to the currently rotated image view. * @param {number} currentRotation - The rotation angle of the current view (0, 90, 180, 270 degrees). * @param {number} originalWidth - Width of the original (0-degree) image. * @param {number} originalHeight - Height of the original (0-degree) image. * @returns {Corners | null} - Transformed base corner coordinates, or null if input is invalid. */ export declare function transformDisplayCornersToBase(displayCorners: ReadonlyArray<Point>, currentRotation: number, originalWidth: number, originalHeight: number): Corners | null; /** * Calculates the area of a quadrilateral defined by four points using the Shoelace formula. * Assumes points are ordered (e.g., TL, TR, BR, BL). * @param {ReadonlyArray<Point>} points - Array of 4 corner points. * @returns {number} - The area of the quadrilateral. */ export declare function calculateAreaFromPoints(points: ReadonlyArray<Point>): number; /** * Generates default square corners for an image with a specific pixel inset. * @param {number} imageWidth - The width of the image. * @param {number} imageHeight - The height of the image. * @param {number} insetPixels - The inset in pixels from each edge. * @returns {Corners} - An array of 4 Point objects representing the corners (TL, TR, BR, BL). */ export declare function generateDefaultCornersPx(imageWidth: number, imageHeight: number, insetPixels: number): Corners; //# sourceMappingURL=imageProcessing.d.ts.map