An image "scanning" app written in Python using OpenCV.
An improved version of my Image scanner, a standalone app that takes a 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 may work with other versions, but this is the version that was used during development.
- Download
Image Scanner.zipand extract its contents into a folder.
Tip
Create a shortcut for Image Scanner/Image Scanner.exe outside the folder for easier access.
- Create a new directory, for example
scanner, and placeimageScanner.pyandscanner.icoinside 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 required packages:
pip install opencv-contrib-python matplotlib
To create Image Scanner/Image Scanner.exe, use the following command:
pyinstaller --onedir --icon=scanner.ico --add-data="scanner.ico;." --windowed --name="Image Scanner" imageScanner.py
Note
The 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 colors aren't distinct enough.