UNPKG

ppu-paddle-ocr

Version:

Blazing-fast and lightweight PaddleOCR library for Node.js and Bun. Perform accurate text detection, recognition, and image deskew with a simple, modern, and type-safe API. Ideal for document processing, data extraction, and computer vision tasks.

39 lines (38 loc) 1.43 kB
import { type Canvas } from "ppu-ocv"; import type { DebuggingOptions, DetectionOptions } from "../interface.js"; export declare class DeskewService { private readonly options; private readonly debugging; constructor(options?: Partial<DetectionOptions>, debugging?: Partial<DebuggingOptions>); /** * Logs a message if verbose debugging is enabled */ private log; /** * Runs a lightweight detection pass to determine the average text skew angle. * Uses multiple methods to robustly calculate skew from all detected text regions. * @param probabilityMapCanvas - The canvas containing the probability map of text regions. * @returns The calculated skew angle in degrees. */ calculateSkewAngle(probabilityMapCanvas: Canvas): Promise<number>; /** * Calculate angles using minimum area rectangles around text regions */ private calculateMinRectAngles; /** * Calculate angles by analyzing text baselines using contour points */ private calculateBaselineAngles; /** * Calculate angles using Hough line transform for dominant lines */ private calculateHoughAngles; /** * Calculate angle from a set of points using linear regression */ private calculateLineAngle; /** * Calculate consensus angle from multiple measurements using robust statistics */ private calculateConsensusAngle; }