UNPKG

ppu-ocv

Version:

A type-safe, modular, chainable image processing library built on top of OpenCV.js with a fluent API leveraging pipeline processing.

55 lines (54 loc) 1.72 kB
import type { BoundingBox } from "./index.interface.js"; import type { CanvasLike, Context2DLike } from "./canvas-factory.js"; /** Structural type for contour-like objects with 32-bit signed integer point data. */ export type ContourLike = { /** Flat `[x0, y0, x1, y1, ...]` point array. Matches `cv.Mat.data32S` for contour Mats. */ data32S: Int32Array | number[]; }; /** * Cross-platform base class for canvas manipulation utilities. * Contains only methods that work in both Node and browser environments. */ export declare class CanvasToolkitBase { protected static _baseInstance: CanvasToolkitBase | null; protected step: number; protected constructor(); /** Return the singleton instance of {@link CanvasToolkitBase}. */ static getInstance(): CanvasToolkitBase; /** * Crop a part of source canvas and return a new canvas of the cropped part */ crop(options: { bbox: BoundingBox; canvas: CanvasLike; }): CanvasLike; /** * Check whether a binary canvas is dirty (full of major color either black or white) or not */ isDirty(options: { canvas: CanvasLike; threshold?: number; majorColorThreshold?: number; }): boolean; /** * Draw a non-filled rectangle on the canvas */ drawLine(options: { ctx: Context2DLike; x: number; y: number; width: number; height: number; lineWidth?: number; color?: string; }): void; /** * Draw a contour on the canvas */ drawContour(options: { ctx: Context2DLike; contour: ContourLike; strokeStyle?: string; lineWidth?: number; }): void; }