In one of the companies I worked for, there was a need to scan various books. To accomplish this, we either had to pay a significant cost or scan each page individually in a suitable format and then edit them using image editing software. Also we must follow these steps:
- Align image
- Remove any background
- Keep the quality of original image
- Get a white scanned image with its text and image
I wanted to find a suitable solution using machine learning. Initially, I used the article from “Varun” in learningopencv.
However, there were several issues:
It was not suitable for every paper size, couldn’t accurately detect the edges of the papers, and the final file had a decrease in quality. It did not remove colored or grayscale backgrounds.
So, I developed this code and addressed these issues. In this project, the OpenCV and NumPy libraries were used. Additionally, Canny Edge Detection was employed, and Homography was used for perspective transformation. Finally, I configured the IP camera with Python, and we were able to have a scanner that could scan any type of paper with any color, size, and angle with good quality.
I use these libraries for virtual scanner:
Numpy, OpenCV.
The briefly steps are:
1- Morphology
2- Canny Edge Detection
3- Contours
4- Corner Detection using Douglas-Peucker algorithm
5- Homography
6- Perspective Transform