This repository implements a document scanner in Python as part of the "Artificial Vision" course at URJC. The application takes a photo of a paper document and outputs a rectified (top-down) view of the paper, mimicking the result of a traditional scanner.
- Detects the four corner points of a paper document using Harris keypoints and SIFT descriptors.
- Applies image thresholding and morphological operations to clean up the image.
- Matches keypoints against a reference set to localize corners.
- Performs a perspective transform to generate a scanned version of the document.
- Includes a test mode that batch-processes a folder of images and displays results interactively.
- Python 3.12
- OpenCV 4.11
- NumPy
- SciPy
- Matplotlib
- Pandas
python scanner.py path/to/image.jpgpython scanner.py --test path/to/test_folderThe system expects a CSV file with manually labeled corner points and a folder with the corresponding reference images:
learning_corner_points.csvmuestraTrainTest/learning/
These are used to compute reference descriptors used in corner detection.
- Transformed (rectified) document image.
- In test mode, displays side-by-side visualization of preprocessing and corner detection.
scanner.py # Main program
learning_corner_points.csv # CSV with labeled corner points
muestraTrainTest/ # Contains training and test images
Install the required packages with:
pip install -r requirements.txt- Corner detection may fail if document edges are not clearly visible or poorly illuminated.