An image "scanning" app written in Python using OpenCV.
Description: an improvement of my Image scanner, a standalone app that takes an photo of a paper, and outputs an edited image with the paper properly aligned as though it was scanned.
- Python 3.7.0
The app could work with different versions, but this is the one that was tested.
- Download
Image Scanner.zip
and extract its contents into a folder.
Tip
Create a shortcut for Image Scanner/Image Scanner.exe
outside the folder to easily access the app.
- Create a new directory, for example
scanner
, and placeimageScanner.py
andscanner.ico
inside of it. - Open the directory in your Terminal:
cd scanner
- Create a virtual environment:
python -m venv opencv-env
- Activate the environment :
.\opencv-env\Scripts\activate
- Install needed packages:
pip install opencv-contrib-python matplotlib
To create Image Scanner/Image Scanner.exe
the following command was used:
pyinstaller --onedir --icon=scanner.ico --add-data="scanner.ico;." --windowed --name="Image Scanner" imageScanner.py
While
scanner.ico
is the icon used for the app.
If you don't want to use an icon you can remove the following line from imageScanner.py
:
root.iconbitmap("scanner.ico")
And create an executable using:
pyinstaller --onedir --windowed --name="Image Scanner" imageScanner.py
- Run
Image Scanner/Image Scanner.exe
(orimageScanner.py
). - Choose an image to edit.
- Choose a location to export the new image to and name it.
Note
Common causes for failing to process the image:
- The paper isn't visible in its entirety in the input image.
- The paper and the background color aren't distinct enough in the input image.