Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
---
|
| 4 |
+
# Document Scanner :bookmark_tabs:
|
| 5 |
+
[U-Net](https://arxiv.org/abs/1505.04597v1) Like Pretrained Model For Scene Document Detection ([pytorch](https://pytorch.org/), [Semantic Segmentation](https://paperswithcode.com/task/semantic-segmentation))
|
| 6 |
+
|
| 7 |
+
#### **Quick Links**
|
| 8 |
+
- [Dependencies](#Dependencies)
|
| 9 |
+
- [Usage](#Usage)
|
| 10 |
+
- [Examples](#Examples)
|
| 11 |
+
|
| 12 |
+
## Dependencies
|
| 13 |
+
- Install Dependencies `$ pip install -r requirements.txt`
|
| 14 |
+
- Download model weights [Here](), place it in `Structure/`
|
| 15 |
+
|
| 16 |
+
## Usage:
|
| 17 |
+
```python
|
| 18 |
+
scanner = Scanner("Structure/Scanner-Detector.pth", config_)
|
| 19 |
+
```
|
| 20 |
+
Load model.
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
org = cv2.imread(fname)
|
| 24 |
+
org_gray = cv2.cvtColor(org, cv2.COLOR_RGB2GRAY)
|
| 25 |
+
org_resize = cv2.resize(org_gray, (256, 256), interpolation = cv2.INTER_AREA)
|
| 26 |
+
```
|
| 27 |
+
Read image in gray scale and resize it to 256*256.
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
mask = scanner.ScanView(org_resize)
|
| 31 |
+
```
|
| 32 |
+
Detect document area.
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
paper, approx = ExtractPaper(org_gray, mask)
|
| 36 |
+
org = DrawBox(org, approx)
|
| 37 |
+
```
|
| 38 |
+
Extract document and draw bounding box on original image.
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
paper = EnhacePaper(paper)
|
| 42 |
+
```
|
| 43 |
+
Enhance extracted document.
|
| 44 |
+
|
| 45 |
+
## Examples
|
| 46 |
+
|
| 47 |
+

|
| 48 |
+

|
| 49 |
+

|
| 50 |
+

|
| 51 |
+

|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
### 🛡️ License <a name="license"></a>
|
| 55 |
+
Project is distributed under [MIT License](https://github.com/Saeed-Biabani/Document-Scanner/blob/main/LICENSE)
|