Hello!
I present You a simple script, that can help you to scan Game Cards, or Photos, multiple at once. I've made it as a project for my university, it was meant to preserve old images and cards I had.
It basically finds the individual cards/photos, extracts them and rotates them to straight orientation.
I share it with You under Creative Commons Licence. Please respect that.
Few assumptions:
- Place game cards/Photos in ( more or less ) straight orientation, avoid 45° rotation
- Scan to multi-page PDF, place the file name in line
66
- DO NOT overlap images, about 3-5 mm margin is safe, otherwise script may detect two images as one!
- Remember - usually scanners are not scanning anything that's placed to about 3 mm from edges
- If you'd like to scan cards with white borders - do not close the lid, change
white_cards
toTrue
- For Photos you may need to change the
cv.threshold()
on line17
to something likecv.threshold(gray, 240, 255, cv.THRESH_BINARY_INV)
Needed packages:
pip install opencv-python PyMuPDF numpy
I have a problem, it raises FileNotFouiundError: no such file: "filename.pdf" , where it is supposed to leave the filename.pdf?
I did scanned and then saved as filename.pdf in the same folder as the python script.
Some help ? :)