scanic 0.1.4 → 0.1.5

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.
package/README.md CHANGED
@@ -27,7 +27,7 @@ This library is heavily inspired by [jscanify](https://github.com/puffinsoft/jsc
27
27
  - 🦀 **Rust WebAssembly**: Performance-critical operations optimized with Rust-compiled WASM
28
28
  - 🛠️ **Easy Integration**: Simple API for web apps, Electron, or Node.js applications
29
29
  - 🏷️ **MIT Licensed**: Free for personal and commercial use
30
- - 📦 **Lightweight**: Small bundle size compared to OpenCV-based solutions
30
+ - 📦 **Lightweight**: Small bundle size (< 100kb) compared to OpenCV-based solutions (+30 mb)
31
31
 
32
32
  ## Demo
33
33
 
@@ -112,14 +112,13 @@ Main entry point for document scanning with flexible modes and output options.
112
112
  **Parameters:**
113
113
  - `image`: HTMLImageElement, HTMLCanvasElement, or ImageData
114
114
  - `options`: Optional configuration object
115
- - `mode`: String - 'detect' (default), 'highlight', or 'extract'
115
+ - `mode`: String - 'detect' (default), or 'extract'
116
116
  - `'detect'`: Only detect document, return corners/contour info (no image processing)
117
- - `'highlight'`: Draw outline on original image
118
117
  - `'extract'`: Extract/warp the document region
119
118
  - `output`: String - 'canvas' (default), 'imagedata', or 'dataurl'
120
119
  - `debug`: Boolean (default: false) - Enable debug information
121
120
  - Detection options:
122
- - `maxProcessingDimension`: Number (default: 800) - Maximum dimension for processing
121
+ - `maxProcessingDimension`: Number (default: 800) - Maximum dimension for processing in pixels
123
122
  - `lowThreshold`: Number (default: 75) - Lower threshold for Canny edge detection
124
123
  - `highThreshold`: Number (default: 200) - Upper threshold for Canny edge detection
125
124
  - `dilationKernelSize`: Number (default: 3) - Kernel size for dilation
@@ -135,37 +134,6 @@ Main entry point for document scanning with flexible modes and output options.
135
134
  - `success`: Boolean indicating if document was detected
136
135
  - `message`: Status message
137
136
 
138
- ### Live Scanner
139
-
140
- #### `LiveScanner`
141
- Real-time document scanner for webcam integration.
142
-
143
- **Constructor Options:**
144
- - `targetFPS`: Number (default: 10) - Target frames per second
145
- - `detectionInterval`: Number (default: 150) - Milliseconds between detections
146
- - `confidenceThreshold`: Number (default: 0.7) - Confidence threshold for detections
147
- - `stabilizationFrames`: Number (default: 3) - Frames needed for stable detection
148
- - `maxProcessingDimension`: Number (default: 500) - Max dimension for live processing
149
-
150
- **Methods:**
151
- - `init(outputElement, constraints)` - Initialize webcam and start scanning
152
- - `stop()` - Stop scanning and release resources
153
- - `pause()` - Pause scanning
154
- - `resume()` - Resume scanning
155
- - `capture()` - Capture current frame
156
-
157
- **Events:**
158
- - `onDetection(result)` - Called when document is detected
159
- - `onFPSUpdate(fps)` - Called with current FPS
160
- - `onError(error)` - Called on errors
161
-
162
- #### `checkWebcamAvailability()`
163
- Checks if webcam is available and lists video devices.
164
-
165
- **Returns:** `Promise<{ available: boolean, deviceCount?: number, devices?: Array, error?: string }>`
166
-
167
- All functions work in both browser and Node.js environments. For Node.js, use a compatible canvas/image implementation like `canvas` or `node-canvas`.
168
-
169
137
  ## Examples
170
138
 
171
139
  ```js
@@ -194,12 +162,6 @@ const extracted = await scanDocument(imageElement, {
194
162
  output: 'canvas'
195
163
  });
196
164
 
197
- // Highlight as data URL
198
- const highlighted = await scanDocument(imageElement, {
199
- mode: 'highlight',
200
- output: 'dataurl'
201
- });
202
-
203
165
  // Extract as ImageData
204
166
  const rawData = await scanDocument(imageElement, {
205
167
  mode: 'extract',
@@ -207,43 +169,6 @@ const rawData = await scanDocument(imageElement, {
207
169
  });
208
170
  ```
209
171
 
210
- ### Live Scanner Usage
211
-
212
- ```js
213
- import { LiveScanner, checkWebcamAvailability } from 'scanic';
214
-
215
- // Check if webcam is available
216
- const webcamStatus = await checkWebcamAvailability();
217
- if (!webcamStatus.available) {
218
- console.error('No webcam available');
219
- return;
220
- }
221
-
222
- // Create live scanner
223
- const liveScanner = new LiveScanner({
224
- targetFPS: 15,
225
- detectionInterval: 100,
226
- maxProcessingDimension: 600
227
- });
228
-
229
- // Set up event handlers
230
- liveScanner.onDetection = (result) => {
231
- if (result.success) {
232
- console.log('Document detected:', result.corners);
233
- }
234
- };
235
-
236
- liveScanner.onFPSUpdate = (fps) => {
237
- console.log('Current FPS:', fps);
238
- };
239
-
240
- // Start scanning
241
- const outputCanvas = document.getElementById('scanner-output');
242
- await liveScanner.init(outputCanvas);
243
-
244
- // Stop scanning when done
245
- // liveScanner.stop();
246
- ```
247
172
 
248
173
  ## Development
249
174
 
@@ -292,8 +217,6 @@ Scanic uses a **hybrid JavaScript + WebAssembly approach**:
292
217
  - Non-maximum suppression for edge thinning
293
218
  - Morphological operations (dilation/erosion)
294
219
 
295
- The WASM module is compiled from Rust using `wasm-bindgen` and includes fixed-point arithmetic optimizations for better performance on integer operations.
296
-
297
220
  ## Contributing
298
221
 
299
222
  Contributions are welcome! Here's how you can help:
@@ -307,15 +230,51 @@ Contributions are welcome! Here's how you can help:
307
230
  - Push to the branch (`git push origin feature/amazing-feature`)
308
231
  - Open a Pull Request
309
232
 
310
- Please ensure your code follows the existing style and includes appropriate tests.
233
+ Please ensure your code follows the existing style.
311
234
 
312
- ## Sponsors
235
+ ## 💖 Sponsors
313
236
 
314
- [zeugnisprofi](https://zeugnisprofi.com)
315
-
316
- [zeugnisprofi.de] (https://zeugnisprofi.de)
237
+ <p align="center">
238
+ <strong>Special thanks to our amazing sponsors who make this project possible!</strong>
239
+ </p>
317
240
 
318
- [verlingo](https://www.verlingo.de)
241
+ <div align="center">
242
+
243
+ ### 🏆 Gold Sponsors
244
+
245
+ <table>
246
+ <tr>
247
+ <td align="center" width="300">
248
+ <a href="https://zeugnisprofi.com" target="_blank">
249
+ <img src="https://via.placeholder.com/200x80/4A90E2/FFFFFF?text=ZeugnisProfi" alt="ZeugnisProfi" width="200"/>
250
+ <br/>
251
+ <strong>ZeugnisProfi</strong>
252
+ </a>
253
+ <br/>
254
+ <em>Professional certificate and document services</em>
255
+ </td>
256
+ <td align="center" width="300">
257
+ <a href="https://zeugnisprofi.de" target="_blank">
258
+ <img src="https://via.placeholder.com/200x80/50C878/FFFFFF?text=ZeugnisProfi.de" alt="ZeugnisProfi.de" width="200"/>
259
+ <br/>
260
+ <strong>ZeugnisProfi.de</strong>
261
+ </a>
262
+ <br/>
263
+ <em>German document processing specialists</em>
264
+ </td>
265
+ <td align="center" width="250">
266
+ <a href="https://www.verlingo.de" target="_blank">
267
+ <img src="https://via.placeholder.com/180x70/FF6B35/FFFFFF?text=Verlingo" alt="Verlingo" width="180"/>
268
+ <br/>
269
+ <strong>Verlingo</strong>
270
+ </a>
271
+ <br/>
272
+ <em>Language and translation services</em>
273
+ </td>
274
+ </tr>
275
+ </table>
276
+
277
+ </div>
319
278
 
320
279
  ## Roadmap
321
280
 
@@ -331,4 +290,3 @@ Please ensure your code follows the existing style and includes appropriate test
331
290
 
332
291
  MIT License © [marquaye](https://github.com/marquaye)
333
292
 
334
- See [LICENSE](LICENSE) for more details.