@@ -32,6 +32,7 @@ OpenCV is powerful but can be cumbersome to use directly. This library provides:
32323 . ** Development Speed** : Add image processing to your app in minutes, not hours
33334 . ** Extensibility** : Custom operations for your specific needs without library modifications
34345 . ** TypeScript Integration** : Full IntelliSense support with parameter validation
35+ 6 . ** Web Support** : Supports running directly in the browser
3536
3637## Installation
3738
@@ -57,7 +58,10 @@ const canvas = await ImageProcessor.prepareCanvas(image);
5758await ImageProcessor .initRuntime ();
5859
5960const processor = new ImageProcessor (canvas );
60- processor .grayscale ().blur ({ size: [5 , 5 ] }).threshold ();
61+ processor
62+ .grayscale ()
63+ .blur ({ size: [5 , 5 ] })
64+ .threshold ();
6165
6266const resultCanvas = processor .toCanvas ();
6367processor .destroy ();
@@ -113,7 +117,10 @@ const buffer = await response.arrayBuffer();
113117const canvas = await ImageProcessor .prepareCanvas (buffer );
114118const processor = new ImageProcessor (canvas );
115119
116- processor .grayscale ().blur ({ size: [5 , 5 ] }).threshold ();
120+ processor
121+ .grayscale ()
122+ .blur ({ size: [5 , 5 ] })
123+ .threshold ();
117124
118125const result = processor .toCanvas (); // returns HTMLCanvasElement
119126document .body .appendChild (result );
@@ -131,7 +138,10 @@ processor.destroy();
131138 await ImageProcessor .initRuntime ();
132139
133140 const processor = new ImageProcessor (canvas);
134- processor .grayscale ().blur ({ size: [5 , 5 ] }).threshold ();
141+ processor
142+ .grayscale ()
143+ .blur ({ size: [5 , 5 ] })
144+ .threshold ();
135145
136146 const result = processor .toCanvas ();
137147 processor .destroy ();
@@ -144,14 +154,14 @@ See the [interactive demo](./index.html) for a full working example.
144154
145155### Node vs Web differences
146156
147- | Feature | ` ppu-ocv ` (Node) | ` ppu-ocv/web ` (Browser) |
148- | --- | --- | --- |
149- | Canvas backend | ` @napi-rs/canvas ` | ` HTMLCanvasElement ` / ` OffscreenCanvas ` |
150- | ` CanvasToolkit ` | Full (includes ` saveImage ` , ` clearOutput ` ) | Base only (` crop ` , ` isDirty ` , ` drawLine ` , ` drawContour ` ) |
151- | File I/O | ✅ ` saveImage ` , ` clearOutput ` | ❌ Not available (use download links or ` toDataURL ` ) |
152- | ` ImageProcessor ` | ✅ | ✅ Same API |
153- | ` Contours ` | ✅ | ✅ Same API |
154- | Image analysis | ✅ | ✅ Same API |
157+ | Feature | ` ppu-ocv ` (Node) | ` ppu-ocv/web ` (Browser) |
158+ | ---------------- | ------------------------------------------ | ----------------------------------------------------- --- |
159+ | Canvas backend | ` @napi-rs/canvas ` | ` HTMLCanvasElement ` / ` OffscreenCanvas ` |
160+ | ` CanvasToolkit ` | Full (includes ` saveImage ` , ` clearOutput ` ) | Base only (` crop ` , ` isDirty ` , ` drawLine ` , ` drawContour ` ) |
161+ | File I/O | ✅ ` saveImage ` , ` clearOutput ` | ❌ Not available (use download links or ` toDataURL ` ) |
162+ | ` ImageProcessor ` | ✅ | ✅ Same API |
163+ | ` Contours ` | ✅ | ✅ Same API |
164+ | Image analysis | ✅ | ✅ Same API |
155165
156166### Platform abstraction
157167
@@ -161,9 +171,15 @@ Under the hood, ppu-ocv uses a platform abstraction layer. The `ppu-ocv` entry p
161171import { setPlatform , type CanvasPlatform } from " ppu-ocv/web" ;
162172
163173const myPlatform: CanvasPlatform = {
164- createCanvas(width , height ) { /* ... */ },
165- loadImage(source ) { /* ... */ },
166- isCanvas(value ) { /* ... */ },
174+ createCanvas(width , height ) {
175+ /* ... */
176+ },
177+ loadImage(source ) {
178+ /* ... */
179+ },
180+ isCanvas(value ) {
181+ /* ... */
182+ },
167183};
168184
169185setPlatform (myPlatform );
0 commit comments