In this repo, I created a Skew Correction for text using OpenCV and Python.
- First, apply the threshold in the grayscale image
- Dilates a threshold image by using a specific structuring element
- Finds and draws contours in a dilated image
- Find the rectangle of the minimum area using contours
- Finally, Wrap Transformation with rectangle co-ordinates
Install pre-requisites packages
pip install -r requirements.txt
or
pip install numpy==1.22.0
pip install opencv-python==4.5.5.62
Am using NumPy version 1.22.0 and OpenCV version 4.5.5, you can be used the updated version.
You can run the python file by giving this below command on your command prompt. Make sure you can use any image you want to give the correct image path after the --image argument.
python SkewCorrection.py --image images/img4.png