Skip to content

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

License

Notifications You must be signed in to change notification settings

davide710/scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

After

After

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

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages