Skip to content

Commit 12b6db8

Browse files
committed
update doc
1 parent 14cccd9 commit 12b6db8

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

README.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ OpenCV is powerful but can be cumbersome to use directly. This library provides:
3232
3. **Development Speed**: Add image processing to your app in minutes, not hours
3333
4. **Extensibility**: Custom operations for your specific needs without library modifications
3434
5. **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);
5758
await ImageProcessor.initRuntime();
5859

5960
const processor = new ImageProcessor(canvas);
60-
processor.grayscale().blur({ size: [5, 5] }).threshold();
61+
processor
62+
.grayscale()
63+
.blur({ size: [5, 5] })
64+
.threshold();
6165

6266
const resultCanvas = processor.toCanvas();
6367
processor.destroy();
@@ -113,7 +117,10 @@ const buffer = await response.arrayBuffer();
113117
const canvas = await ImageProcessor.prepareCanvas(buffer);
114118
const 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

118125
const result = processor.toCanvas(); // returns HTMLCanvasElement
119126
document.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
161171
import { setPlatform, type CanvasPlatform } from "ppu-ocv/web";
162172

163173
const 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

169185
setPlatform(myPlatform);

0 commit comments

Comments
 (0)