Overview
Modern scanning applications, such as CamScanner or built-in iPad scanning tools, employ perspective correction to automatically detect and straighten skewed documents. This process ensures that scanned images appear parallel to the camera viewpoint and aligned properly, eliminating distortions caused by camera angles.
Many existing solutions require manual input—users must provide four corner points of the document to perform perspective transformation. However, a robust automated pipeline can detect these corners and apply corrections without user intervention.
This project implements fully automated perspective correction using computer vision techniques. Given an image of a tilted card or document, the system:
- [ ] Identifies edges and contours
- [ ] Extracts the quadrilateral shape
- [ ] Applies perspective transformation to rectify the angle
- [ ] Enhances the image via sharpening
Pipeline Overview
The high-level workflow consists of the following steps:
- Read Image – Load the image and preprocess it.
- Edge Detection – Use Canny edge detection to extract edges.
- Find Contours & Convex Hull – Identify closed shapes.
- Detect Intersections – Compute the intersection points forming the quadrilateral.
- Validate Quadrilateral Shape – Ensure detected points form a valid four-cornered structure.
- Compute Centroid & Sort Corners – Order the corners correctly for transformation.
- Apply Perspective Transformation – Use homography to correct the skew.
- Warp Image – Perform the transformation to align the document.
- Sharpen & Enhance – Post-process the output for improved clarity.