Skip to content

Commit 5a6060b

Browse files
Andrew CampbellAndrew Campbell
authored andcommitted
Initial commit
0 parents  commit 5a6060b

25 files changed

+600
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pyc
2+
.DS_Store

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Document Scanner
2+
3+
### An interactive document scanner built in Python using OpenCV
4+
5+
The scanner takes a poorly scanned image, finds the corners of the document, applies the perspective transformation to get a top-down view of the document, sharpens the image, and applies an adaptive color threshold to clean up the image.
6+
7+
On my test dataset of 280 images, the program correctly detected the corners of the document 92.8% of the time.
8+
9+
This project makes use of the transform and imutils modules from pyimagesearch (which can be accessed [here](http://www.pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/)). The UI code for the interactive mode is adapted from `poly_editor.py` from [here](https://matplotlib.org/examples/event_handling/poly_editor.html).
10+
11+
* You can manually click and drag the corners of the document to be perspective transformed:
12+
![Example of interactive GUI](https://github.com/andrewdcampbell/doc_scanner/blob/master/ui.gif)
13+
14+
* The scanner can also process an entire directory of images automatically and save the output in an output directory:
15+
![Image Directory of images to be processed](https://github.com/andrewdcampbell/doc_scanner/blob/master/before_after.gif)
16+
17+
18+
### Usage
19+
```
20+
python scan.py (--images <IMG_DIR> | --image <IMG_PATH>) [-i]
21+
```
22+
* For example, to scan a single image with interactive mode:
23+
```
24+
python scan.py --image images/page.jpg -i
25+
```
26+
* To scan all images in a directory automatically:
27+
```
28+
python scan.py --images images
29+
```

before_after.gif

1.63 MB
Loading

output/cell_pic.jpg

1.71 MB
Loading

output/chart.JPG

1.01 MB
Loading

output/desk.JPG

908 KB
Loading

output/dollar_bill.JPG

1.23 MB
Loading

output/math_cheat_sheet.JPG

1.69 MB
Loading

output/notepad.JPG

727 KB
Loading

output/receipt.jpg

467 KB
Loading

0 commit comments

Comments
 (0)