A Python 3
command line script to detect & extract sheets of paper in images, the script use OpenCV and NumPy.
Ensure you have a valid and working python3
, opencv
& numpy
(Normally NumPy is a dependency of OpenCV, so you don't need to worry).
Info : The script has been developed and tested on Python 3.11.0
& OpenCV 4.6.0
.
After cloning (or downloading) this repository:
python3 ipex.py -i ~/Desktop/IMG_3212.png
The paper sheets images extracted will be saved into a newly created folder inside ./results/
, if nothing has been generated please check the log in your terminal.
You can pass one or more images/photographs to the script like this:
python3 ipex.py -i ~/Desktop/IMG_3205.png ./contract.jpg ~/Documents/invoice.jpeg
Inside the result subfolder, extracted paper sheets will be named paper_001.png
, paper_002.png
, paper_003.png
, ...
You can visualize some steps of the sheet detection by adding the argument -d
or --debug
to the script call:
python3 ipex.py -i ~/Documents/homework_03.jpeg -d
This will add debug images into the result subfolder.
In case of an error you should see a formated log message in your terminal telling you exactly what is the issue. If the script crash or something don't work you can open an issue here.
- use
numpy.ascontiguousarray
on images arrays to use them as output or dest array, reducing allocations - Adding more timing debug to detect bottle necks in the process
- Expose
is_document
andmax_quality
to script arguments
IPEX has been created and is currently maintained by Ben Souchet.
The code present in this repository is under MIT license.