@uziee/document-scanner 1.1.7 → 1.1.9
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 +48 -7
- package/dist/index.es.js +713 -538
- package/dist/index.umd.js +11 -11
- package/dist/style.css +1 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# @uziee/document-scanner
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@uziee/document-scanner)
|
|
4
|
+
[](https://github.com/uzair2244/document-scanner/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
A high-performance, lightweight React component for real-time document detection, stability filtering, and perspective-corrected scanning.
|
|
7
|
+
|
|
8
|
+
## 🔗 [Live Demo](https://document-scanner.vercel.app)
|
|
9
|
+
|
|
10
|
+
> **Try it now:** [https://document-scanner.vercel.app](https://document-scanner.vercel.app)
|
|
4
11
|
|
|
5
12
|
## 🚀 Key Features
|
|
6
13
|
|
|
@@ -9,6 +16,7 @@ A high-performance, lightweight React component for real-time document detection
|
|
|
9
16
|
* **Bilinear Warp Transformation:** Automatically "flattens" skewed documents into a clean, rectangular A4-proportioned image.
|
|
10
17
|
* **Zero Dependencies:** Runs entirely on native Canvas API—no massive WASM files or external ML models.
|
|
11
18
|
* **High-Res Capture:** Analyzes a low-res stream for performance but captures the final document from the full-resolution camera feed.
|
|
19
|
+
* **Close Button:** Users can exit the scanner anytime without capturing.
|
|
12
20
|
|
|
13
21
|
---
|
|
14
22
|
|
|
@@ -20,7 +28,16 @@ npm install @uziee/document-scanner
|
|
|
20
28
|
|
|
21
29
|
## 📖 Usage
|
|
22
30
|
|
|
23
|
-
Import the `DocumentScanner` component into your React application and provide
|
|
31
|
+
Import the `DocumentScanner` component into your React application and provide the callback props to handle scanning events.
|
|
32
|
+
|
|
33
|
+
### Props
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Required | Description |
|
|
36
|
+
|------|------|----------|-------------|
|
|
37
|
+
| `onCapture` | `(images: string[]) => void` | Yes | Callback fired when user finishes scanning. Receives an array of base64 image data URLs. |
|
|
38
|
+
| `onClose` | `() => void` | No | Callback fired when user taps the close button (X) to exit the scanner without capturing. |
|
|
39
|
+
|
|
40
|
+
### Example
|
|
24
41
|
|
|
25
42
|
```jsx
|
|
26
43
|
import React, { useState } from 'react';
|
|
@@ -28,18 +45,33 @@ import DocumentScanner from '@uziee/document-scanner';
|
|
|
28
45
|
|
|
29
46
|
function App() {
|
|
30
47
|
const [showScanner, setShowScanner] = useState(false);
|
|
48
|
+
const [scannedImages, setScannedImages] = useState([]);
|
|
31
49
|
|
|
32
50
|
const handleCapture = (images) => {
|
|
33
|
-
images.
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
console.log(`Captured ${images.length} document(s)`);
|
|
52
|
+
setScannedImages(images);
|
|
53
|
+
setShowScanner(false);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const handleClose = () => {
|
|
57
|
+
// User closed the scanner without capturing
|
|
36
58
|
setShowScanner(false);
|
|
37
59
|
};
|
|
38
60
|
|
|
39
61
|
return (
|
|
40
62
|
<div>
|
|
41
63
|
<button onClick={() => setShowScanner(true)}>Scan Document</button>
|
|
42
|
-
|
|
64
|
+
|
|
65
|
+
{showScanner && (
|
|
66
|
+
<DocumentScanner
|
|
67
|
+
onCapture={handleCapture}
|
|
68
|
+
onClose={handleClose}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
{scannedImages.map((img, i) => (
|
|
73
|
+
<img key={i} src={img} alt={`Scanned ${i + 1}`} />
|
|
74
|
+
))}
|
|
43
75
|
</div>
|
|
44
76
|
);
|
|
45
77
|
}
|
|
@@ -47,4 +79,13 @@ function App() {
|
|
|
47
79
|
export default App;
|
|
48
80
|
```
|
|
49
81
|
|
|
50
|
-
The component renders a full-screen camera interface for document scanning. It detects documents in real-time, applies stability filtering, and captures high-resolution images with perspective correction.
|
|
82
|
+
The component renders a full-screen camera interface for document scanning. It detects documents in real-time, applies stability filtering, and captures high-resolution images with perspective correction.
|
|
83
|
+
|
|
84
|
+
### UI Controls
|
|
85
|
+
|
|
86
|
+
- **Close Button (X)**: Located in the top-right corner. Calls `onClose` to exit without capturing.
|
|
87
|
+
- **Status Indicator**: Shows "POSITION DOCUMENT" or "READY TO SCAN" based on detection state.
|
|
88
|
+
- **Shutter Button**: Captures the current document when detection is stable.
|
|
89
|
+
- **Thumbnail/Done**: Shows captured images count; tap to finish and return all images via `onCapture`.
|
|
90
|
+
|
|
91
|
+
Ensure your application has camera permissions enabled for the component to function properly.
|