Take any phone-taken picture and turn it into a document scan.

sammdu sammdu Last update: Feb 16, 2024

pyimgscan: open-source document scanning tool MIT License

Take a picture with your phone and convert it to a professional-looking scan.

* Usage

$ python3.9 ./pyimgscan.py

usage: pyimgscan.py [-h] -i IMAGE [-I [INVERTED]]

The program will by default output a corrected.png and a thresholded.png

  • -h display the above help message
  • -i specify a path to the source image file
  • -I also output an inverted binary image (white on black) to thresholded_inverted.png

* Dependencies

Python3.9

numpy==1.16.2
opencv-contrib-python==4.2.0.32

can also be found at requirements.txt


* Setup with virtualenv

1. Set up virtual environment:

virtualenv -p python3.9 PyImgScan/
cd ./PyImgScan/
./bin/activate

2. Clone repository:

GitLab
git clone https://gitlab.com/sammdu/pyimgscan.git

GitHub
git clone https://github.com/sammdu/pyimgscan.git

3. Install dependencies:

cd pyimgscan/
pip install -r requirements.txt

4. Test out an example!

python ./pyimgscan.py -i ./test/1.png

Available examples: ./test/1.png ./test/2.jpg ./test/3.jpg


* TODO



References:

imutils https://github.com/jrosebr1/imutils

PyImageSearch https://www.pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/

Subscribe to our newsletter