https://github.com/endalk200/document-scanner
Document scanner written in python using OpenCV and other Computer Vision libraries. Scans image of documents and creates scanned version of the document by running some image manipulations on it.
https://github.com/endalk200/document-scanner
document-scanner opencv pdf scanner
Last synced: about 1 year ago
JSON representation
Document scanner written in python using OpenCV and other Computer Vision libraries. Scans image of documents and creates scanned version of the document by running some image manipulations on it.
- Host: GitHub
- URL: https://github.com/endalk200/document-scanner
- Owner: endalk200
- License: mit
- Created: 2020-11-21T08:01:37.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-01-18T14:03:49.000Z (over 1 year ago)
- Last Synced: 2025-03-24T09:38:26.519Z (about 1 year ago)
- Topics: document-scanner, opencv, pdf, scanner
- Language: Python
- Homepage:
- Size: 20.1 MB
- Stars: 27
- Watchers: 1
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Document Scanner
### An interactive document scanner built in Python using OpenCV
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.
On my test dataset of 300 images, the program correctly detected the corners of the document 92.8% of the time.
* The scanner can process an entire directory of images automatically and save the output in an output directory:
#### Here are some examples of images before and after scan:




### Usage
You can use this script by downloading it from pypi
```bash
pip install document-scanner
```
aftter installing it from pypi index, you can use it from the terminal as follows.
```
python scan.py (--images | --image ) [-i]
```
* The `-i` flag enables interactive mode, where you will be prompted to click and drag the corners of the document. For example, to scan a single image with interactive mode enabled:
```
python scan.py --image sample_images/desk.JPG -i
```
* Alternatively, to scan all images in a directory without any input:
```
python scan.py --images sample_images
```