scanic 0.1.4 → 0.1.6

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
@@ -1,9 +1,16 @@
1
1
  <p align="center">
2
2
  <a href="#">
3
- <img src="./public/scanic-logo-bg.png" alt="scanic logo" height="400">
3
+ <img src="public/scanic-logo-bg.png" alt="scanic logo" height="400">
4
4
  </a>
5
5
  </p>
6
6
 
7
+ <p align="center">
8
+ <a href="https://npmjs.com/package/scanic"><img src="https://badgen.net/npm/dw/scanic"></a>
9
+ <br />
10
+ <a href="https://github.com/marquaye/scanic/blob/master/LICENSE"><img src="https://img.shields.io/github/license/marquaye/scanic.svg"></a>
11
+ <a href="https://npmjs.com/package/jscanic"><img src="https://badgen.net/npm/v/scanic"></a>
12
+ </p>
13
+
7
14
  # Scanic
8
15
 
9
16
  **Modern Document Scanner for the Web**
@@ -27,7 +34,7 @@ This library is heavily inspired by [jscanify](https://github.com/puffinsoft/jsc
27
34
  - 🦀 **Rust WebAssembly**: Performance-critical operations optimized with Rust-compiled WASM
28
35
  - 🛠️ **Easy Integration**: Simple API for web apps, Electron, or Node.js applications
29
36
  - 🏷️ **MIT Licensed**: Free for personal and commercial use
30
- - 📦 **Lightweight**: Small bundle size compared to OpenCV-based solutions
37
+ - 📦 **Lightweight**: Small bundle size (< 100kb) compared to OpenCV-based solutions (+30 mb)
31
38
 
32
39
  ## Demo
33
40
 
@@ -48,7 +55,7 @@ Or use via CDN:
48
55
  ## Usage
49
56
 
50
57
  ```js
51
- import { scanDocument, LiveScanner, checkWebcamAvailability } from 'scanic';
58
+ import { scanDocument } from 'scanic';
52
59
 
53
60
  // Simple usage - just detect document
54
61
  const result = await scanDocument(imageElement);
@@ -112,14 +119,13 @@ Main entry point for document scanning with flexible modes and output options.
112
119
  **Parameters:**
113
120
  - `image`: HTMLImageElement, HTMLCanvasElement, or ImageData
114
121
  - `options`: Optional configuration object
115
- - `mode`: String - 'detect' (default), 'highlight', or 'extract'
122
+ - `mode`: String - 'detect' (default), or 'extract'
116
123
  - `'detect'`: Only detect document, return corners/contour info (no image processing)
117
- - `'highlight'`: Draw outline on original image
118
124
  - `'extract'`: Extract/warp the document region
119
125
  - `output`: String - 'canvas' (default), 'imagedata', or 'dataurl'
120
126
  - `debug`: Boolean (default: false) - Enable debug information
121
127
  - Detection options:
122
- - `maxProcessingDimension`: Number (default: 800) - Maximum dimension for processing
128
+ - `maxProcessingDimension`: Number (default: 800) - Maximum dimension for processing in pixels
123
129
  - `lowThreshold`: Number (default: 75) - Lower threshold for Canny edge detection
124
130
  - `highThreshold`: Number (default: 200) - Upper threshold for Canny edge detection
125
131
  - `dilationKernelSize`: Number (default: 3) - Kernel size for dilation
@@ -135,37 +141,6 @@ Main entry point for document scanning with flexible modes and output options.
135
141
  - `success`: Boolean indicating if document was detected
136
142
  - `message`: Status message
137
143
 
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
144
  ## Examples
170
145
 
171
146
  ```js
@@ -194,57 +169,21 @@ const extracted = await scanDocument(imageElement, {
194
169
  output: 'canvas'
195
170
  });
196
171
 
197
- // Highlight as data URL
198
- const highlighted = await scanDocument(imageElement, {
199
- mode: 'highlight',
200
- output: 'dataurl'
201
- });
202
-
203
172
  // Extract as ImageData
204
173
  const rawData = await scanDocument(imageElement, {
205
174
  mode: 'extract',
206
175
  output: 'imagedata'
207
176
  });
208
- ```
209
-
210
- ### Live Scanner Usage
211
177
 
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
178
+ // Extract as DataURI
179
+ const rawData = await scanDocument(imageElement, {
180
+ mode: 'extract',
181
+ output: 'dataurl'
227
182
  });
228
183
 
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
184
  ```
247
185
 
186
+
248
187
  ## Development
249
188
 
250
189
  Clone the repository and set up the development environment:
@@ -292,8 +231,6 @@ Scanic uses a **hybrid JavaScript + WebAssembly approach**:
292
231
  - Non-maximum suppression for edge thinning
293
232
  - Morphological operations (dilation/erosion)
294
233
 
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
234
  ## Contributing
298
235
 
299
236
  Contributions are welcome! Here's how you can help:
@@ -307,15 +244,51 @@ Contributions are welcome! Here's how you can help:
307
244
  - Push to the branch (`git push origin feature/amazing-feature`)
308
245
  - Open a Pull Request
309
246
 
310
- Please ensure your code follows the existing style and includes appropriate tests.
311
-
312
- ## Sponsors
247
+ Please ensure your code follows the existing style.
313
248
 
314
- [zeugnisprofi](https://zeugnisprofi.com)
249
+ ## 💖 Sponsors
315
250
 
316
- [zeugnisprofi.de] (https://zeugnisprofi.de)
251
+ <p align="center">
252
+ <strong>Special thanks to our amazing sponsors who make this project possible!</strong>
253
+ </p>
317
254
 
318
- [verlingo](https://www.verlingo.de)
255
+ <div align="center">
256
+
257
+ ### 🏆 Gold Sponsors
258
+
259
+ <table>
260
+ <tr>
261
+ <td align="center" width="300">
262
+ <a href="https://zeugnisprofi.com" target="_blank">
263
+ <img src="https://via.placeholder.com/200x80/4A90E2/FFFFFF?text=ZeugnisProfi" alt="ZeugnisProfi" width="200"/>
264
+ <br/>
265
+ <strong>ZeugnisProfi</strong>
266
+ </a>
267
+ <br/>
268
+ <em>Professional certificate and document services</em>
269
+ </td>
270
+ <td align="center" width="300">
271
+ <a href="https://zeugnisprofi.de" target="_blank">
272
+ <img src="https://via.placeholder.com/200x80/50C878/FFFFFF?text=ZeugnisProfi.de" alt="ZeugnisProfi.de" width="200"/>
273
+ <br/>
274
+ <strong>ZeugnisProfi.de</strong>
275
+ </a>
276
+ <br/>
277
+ <em>German document processing specialists</em>
278
+ </td>
279
+ <td align="center" width="250">
280
+ <a href="https://www.verlingo.de" target="_blank">
281
+ <img src="https://via.placeholder.com/180x70/FF6B35/FFFFFF?text=Verlingo" alt="Verlingo" width="180"/>
282
+ <br/>
283
+ <strong>Verlingo</strong>
284
+ </a>
285
+ <br/>
286
+ <em>Language and translation services</em>
287
+ </td>
288
+ </tr>
289
+ </table>
290
+
291
+ </div>
319
292
 
320
293
  ## Roadmap
321
294
 
@@ -331,4 +304,3 @@ Please ensure your code follows the existing style and includes appropriate test
331
304
 
332
305
  MIT License © [marquaye](https://github.com/marquaye)
333
306
 
334
- See [LICENSE](LICENSE) for more details.