This project is a document scanner built using OpenCV and Python. It takes an image of a document, detects the document's edges, applies a perspective transform to get a top-down view.
- Automatic Document Detection: Finds the document in the image using edge detection and contour analysis.
- Perspective Correction: Warps the detected document to a flat, top-down view.
- Inverted Output: Option to invert the colors of the output.
opencv-project-template/
│
├── src/
│ ├── main.py # Main application logic
│ └── utils.py # Helper functions for image processing
│
├── assets/ # Input images
│ └── sample.jpg
│
├── results/ # Processed output image
│ └── corrected.png
│
├── requirements.txt # Python dependencies
├── README.md # Project documentation
- Clone the repository:
git clone <repo-link>
- Install the required dependencies:
pip install -r requirements.txt
Run the main.py script from the root directory:
python src/main.py --image assets/sample.jpg-i,--image: Path to the input image (Required).-I,--inverted: Optional flag to invert the output colors.
python src/main.py --image assets/receipt.jpg --invertedThe processed images will be saved in the results/ directory:
corrected.png: The perspective-corrected image.scanned.png(orscanned_inverted.png): The final grayscale output.
Input image:
Output image:
Made by Joel Lijo Mathew.
