I have some content to be feature-detected using OpenCV. Before applying detection to the content itself, I need to detect the angle of perspective distortion and fix it. Probably I can use the idea of how QR-code does it - add several anchors to the image. There won't be any square-shaped content, so the source image may look like:
The 3 squares will be our anchors.
When using OpenCV, as far as I understand, I should do these operations:
- Apply grayscale scheme to the image using
cvtColor
function. - Apply blur using
blur
orGaussianBlur
. - Apply
threshold
andCanny
. - Use
findContours
and analyze the results, find the 3 squares by checking vertices count or similar. - Apply the
perspectiveTransform
andwarpPerspective
functions to analyze the squares positions and apply the corresponding transform to the source image.
The problem is I actually don't understand which parameters should be used, and what is the order of methods calls in step #5. I'm new to coding and maths, so I would appreciate any help, thank you!