An open API service indexing awesome lists of open source software.

https://github.com/davide710/scanner

Your pocket scanner: effortless A4 document capture and transformation into a clean PDF
https://github.com/davide710/scanner

computer-vision opencv python scanner

Last synced: 11 months ago
JSON representation

Your pocket scanner: effortless A4 document capture and transformation into a clean PDF

Awesome Lists containing this project

README

          

# DOCUMENT SCANNER

#### Your pocket scanner: effortless A4 document capture and transformation into a clean PDF

## Key Features

#### There's plenty of similar projects, what is it that makes this repository different (and better) ?

- it's purpose is to do _one_ thing, and to do it right
- lightweight (no heavy models), fast and super-easy to use
- the code detects pixels that are supposed to be white and makes them _white_, so that if you need to print the document you don't have to waste ink
- automatically scan all the images in a directory
- choose if you want the result to be colorized or black and white

## How It Works
- Detects the document using OpenCV.
- Applies perspective transformation to align the sheet.
- Cleans up the background.
- Saves the processed document as an A4 PDF

## Usage
The photo must contain the 4 corners of the sheet (it will obviously work better if there's nothing else in the picture and if the quality is high), and it has to be vertical.

#### Getting Started
```
git clone https://github.com/davide710/scanner.git
```
#### Installing Dependences
```
pip install -r requirements.txt
```
#### Use Case Examples
| Command Line | Description |
|- |- |
|``` python3 src/main.py path/to/image [-c (colorized)] ``` |Scans the image provided by the path |
|```python3 src/main.py path/to/folder [-c (colorized)]``` |Scans all images inside the folder provided by the path |
|```python3 src/main.py . [-c (colorized)]``` |Scans all the images within the current directory |

#### Output
All files generated by the program will be output into the follwing directory:
```
scanned/{file_name}.pdf
```
#### Supported Formats
- jpg
- jpeg
- png

## Example
### Before
![Before](https://github.com/davide710/scanner/assets/106482229/19b6b4f5-96dd-4008-84d5-a2bb81693491)
### After
![After](https://github.com/davide710/scanner/assets/106482229/d017f0bf-7800-4a43-ac22-322aa37a727a)

## Troubleshooting
###### "File not found! Insert a valid path."
- Ensure the path to the file provided is correct
- Try again with an absolute path

###### "No files were found."
- Verify there are valid files within the folder directory provided

###### For persistent issues
- Replace main.py with doc_scan_click.py found within the test_and_others folder
- You will see your document, where you can then manually click the four corners of the sheet

###### The same code is behind https://onlinescanner.pythonanywhere.com/

### WANT TO HELP MAKING THIS BETTER?
I keep uploading many results, trying to show both examples of successful and failed tests and highlight pros and cons of the different ideas I get.
If you want to improve this, if you have an idea to make it better, or if you are having trouble using or setting this up, please raise an issue.
Otherwise, work on one of the improvements I mentioned in the Issues section.
You can also star the repository.

## License
This project is open-source and available under the MIT License.