ppu-ocv 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,44 +2,71 @@
2
2
  * Platform abstraction layer for canvas operations.
3
3
  * Allows ppu-ocv to work with both @napi-rs/canvas (Node) and browser canvas APIs.
4
4
  */
5
- /** Structural type satisfied by both @napi-rs/canvas Canvas and HTMLCanvasElement/OffscreenCanvas */
5
+ /** Structural type satisfied by both @napi-rs/canvas Canvas and HTMLCanvasElement/OffscreenCanvas. */
6
6
  export interface CanvasLike {
7
+ /** Canvas width in pixels. */
7
8
  width: number;
9
+ /** Canvas height in pixels. */
8
10
  height: number;
11
+ /** Return a 2D rendering context for drawing on the canvas. */
9
12
  getContext(contextId: "2d"): any;
13
+ /** Serialize the canvas to a binary buffer (Node-side `@napi-rs/canvas`). Absent on browser canvases. */
10
14
  toBuffer?: (...args: any[]) => Buffer;
15
+ /** Serialize the canvas to a data-URL string (browser canvases). Absent on Node-side `@napi-rs/canvas`. */
11
16
  toDataURL?: (...args: any[]) => string;
12
17
  }
13
- /** Structural type for 2D rendering context */
18
+ /** Structural type for 2D rendering context, matching the cross-runtime subset used by ppu-ocv. */
14
19
  export interface Context2DLike {
20
+ /** The canvas this context is bound to. */
15
21
  canvas: any;
22
+ /** Draw an image, canvas, or bitmap onto the context. Signature follows the standard Canvas2D `drawImage`. */
16
23
  drawImage(...args: any[]): void;
24
+ /** Read raw RGBA pixel data from a rectangular region of the canvas. */
17
25
  getImageData(sx: number, sy: number, sw: number, sh: number): {
18
26
  data: Uint8ClampedArray;
19
27
  width: number;
20
28
  height: number;
21
29
  };
30
+ /** Write raw RGBA pixel data back to the canvas at `(dx, dy)`. */
22
31
  putImageData(imageData: any, dx: number, dy: number): void;
32
+ /** Allocate a blank `ImageData` of the given size. */
23
33
  createImageData(width: number, height: number): any;
34
+ /** Start a new path for stroke/fill commands. */
24
35
  beginPath(): void;
36
+ /** Close the current sub-path by connecting the last point to the first. */
25
37
  closePath(): void;
38
+ /** Move the path cursor to `(x, y)` without drawing. */
26
39
  moveTo(x: number, y: number): void;
40
+ /** Draw a straight line from the current path point to `(x, y)`. */
27
41
  lineTo(x: number, y: number): void;
42
+ /** Stroke the current path with the current `strokeStyle` and `lineWidth`. */
28
43
  stroke(): void;
44
+ /** Stroke an axis-aligned rectangle outline. */
29
45
  strokeRect(x: number, y: number, w: number, h: number): void;
46
+ /** Color, gradient, or pattern used by `stroke` and `strokeRect`. */
30
47
  strokeStyle: string | CanvasGradient | CanvasPattern;
48
+ /** Width in pixels of the line drawn by `stroke` / `strokeRect`. */
31
49
  lineWidth: number;
50
+ /** Color, gradient, or pattern used by `fill` and `fillRect`. */
32
51
  fillStyle: string | CanvasGradient | CanvasPattern;
52
+ /** Fill an axis-aligned rectangle with the current `fillStyle`. */
33
53
  fillRect(x: number, y: number, w: number, h: number): void;
54
+ /** Save the current drawing state (transform, styles) onto the state stack. */
34
55
  save(): void;
56
+ /** Restore the most recently saved drawing state. */
35
57
  restore(): void;
58
+ /** Translate the coordinate system by `(x, y)`. */
36
59
  translate(x: number, y: number): void;
60
+ /** Rotate the coordinate system clockwise by `angle` radians. */
37
61
  rotate(angle: number): void;
38
62
  }
39
- /** Platform-specific canvas operations */
63
+ /** Platform-specific canvas operations. Each runtime entry point registers an implementation via {@link setPlatform}. */
40
64
  export interface CanvasPlatform {
65
+ /** Create a blank canvas of the given width and height. */
41
66
  createCanvas(width: number, height: number): CanvasLike;
67
+ /** Decode an image from a buffer or URL and draw it onto a fresh canvas. */
42
68
  loadImage(source: ArrayBuffer | string): Promise<CanvasLike>;
69
+ /** Type guard for "is this value a canvas of this platform?". */
43
70
  isCanvas(value: unknown): value is CanvasLike;
44
71
  }
45
72
  /** Register the platform-specific canvas implementation */
@@ -1,7 +1,8 @@
1
1
  import type { BoundingBox } from "./index.interface.js";
2
2
  import type { CanvasLike, Context2DLike } from "./canvas-factory.js";
3
- /** Structural interface for contour-like objects with 32-bit signed integer point data */
3
+ /** Structural interface for contour-like objects with 32-bit signed integer point data. */
4
4
  export interface ContourLike {
5
+ /** Flat `[x0, y0, x1, y1, ...]` point array. Matches `cv.Mat.data32S` for contour Mats. */
5
6
  data32S: Int32Array | number[];
6
7
  }
7
8
  /**
@@ -7,6 +7,7 @@ import { CanvasToolkitBase } from "./canvas-toolkit.base.js";
7
7
  export declare class CanvasToolkit extends CanvasToolkitBase {
8
8
  private static _nodeInstance;
9
9
  protected constructor();
10
+ /** Return the singleton instance of {@link CanvasToolkit}. */
10
11
  static getInstance(): CanvasToolkit;
11
12
  /**
12
13
  * Save a canvas to an image file
package/cv-provider.d.ts CHANGED
@@ -18,9 +18,11 @@ type CV = typeof _cvType;
18
18
  */
19
19
  export declare function setCv(instance: CV): void;
20
20
  /**
21
- * TypeScript Declaration Merging:
22
- * By exporting both a `namespace cv` and a `const cv`, consumers importing `{ cv }`
23
- * get BOTH the types (e.g. `cv.Mat`) AND the runtime Proxy object.
21
+ * Type-side companion to the {@link cv} runtime proxy.
22
+ *
23
+ * Re-exports the OpenCV.js type aliases (Mat, Rect, Size, enum constants…) under
24
+ * the `cv.` namespace, so consumers importing `{ cv }` get the types AND the
25
+ * runtime Proxy object via TypeScript's declaration-merging rules.
24
26
  */
25
27
  export declare namespace cv {
26
28
  /** OpenCV Mat (matrix / image buffer). */
package/deskew.d.ts CHANGED
@@ -38,6 +38,10 @@ export interface DeskewOptions {
38
38
  export declare class DeskewService {
39
39
  private readonly verbose;
40
40
  private readonly minimumAreaThreshold;
41
+ /**
42
+ * Create a DeskewService.
43
+ * @param options - Configuration. See {@link DeskewOptions}.
44
+ */
41
45
  constructor(options?: DeskewOptions);
42
46
  private log;
43
47
  /**
@@ -25,8 +25,11 @@ type NameWithOptionalOptions = Exclude<OperationName, NameWithRequiredOptions>;
25
25
  * ```
26
26
  */
27
27
  export declare class ImageProcessor {
28
+ /** Underlying OpenCV Mat. Each operation deletes the previous Mat and replaces this reference. */
28
29
  img: cv.Mat;
30
+ /** Current image width in pixels, kept in sync with `img.cols`. */
29
31
  width: number;
32
+ /** Current image height in pixels, kept in sync with `img.rows`. */
30
33
  height: number;
31
34
  /**
32
35
  * Create an ImageProcessor instance from a Canvas or cv.Mat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ppu-ocv",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "A type-safe, modular, chainable image processing library built on top of OpenCV.js with a fluent API leveraging pipeline processing.",
5
5
  "keywords": [
6
6
  "open-cv",
@@ -54,19 +54,33 @@ export type OperationFunction<T> = (img: cv.Mat, options: T) => OperationResult;
54
54
  * it stays an interface rather than a type alias.
55
55
  */
56
56
  export interface RegisteredOperations {
57
+ /** Adaptive (windowed) thresholding. See {@link AdaptiveThresholdOptions}. */
57
58
  adaptiveThreshold: AdaptiveThresholdOptions;
59
+ /** Gaussian blur. See {@link BlurOptions}. */
58
60
  blur: BlurOptions;
61
+ /** Constant-color border around the image. See {@link BorderOptions}. */
59
62
  border: BorderOptions;
63
+ /** Canny edge detection. See {@link CannyOptions}. */
60
64
  canny: CannyOptions;
65
+ /** Convert Mat depth/channel type. See {@link ConvertOptions}. */
61
66
  convert: ConvertOptions;
67
+ /** Morphological dilation. See {@link DilateOptions}. */
62
68
  dilate: DilateOptions;
69
+ /** Morphological erosion. See {@link ErodeOptions}. */
63
70
  erode: ErodeOptions;
71
+ /** Convert to grayscale via `COLOR_RGBA2GRAY`. See {@link GrayscaleOptions}. */
64
72
  grayscale: GrayscaleOptions;
73
+ /** Bitwise-NOT color inversion. See {@link InvertOptions}. */
65
74
  invert: InvertOptions;
75
+ /** Morphological gradient (dilation minus erosion). See {@link MorphologicalGradientOptions}. */
66
76
  morphologicalGradient: MorphologicalGradientOptions;
77
+ /** Resize to absolute pixel dimensions. See {@link ResizeOptions}. */
67
78
  resize: ResizeOptions;
79
+ /** Affine rotation around a pivot point. See {@link RotateOptions}. */
68
80
  rotate: RotateOptions;
81
+ /** Global threshold (including Otsu). See {@link ThresholdOptions}. */
69
82
  threshold: ThresholdOptions;
83
+ /** Four-point perspective warp. See {@link WarpOptions}. */
70
84
  warp: WarpOptions;
71
85
  }
72
86
  /** Union of all registered operation names. Extend {@link RegisteredOperations} to add new ones. */