I am trying to make a lot of building images' horizontal perspective corrected.
like this:
My plan was:
- detect all long straight;
- find the nearly horizontal lines;
- try to make them parallel with a perspective transform, so the building is horizontally placed.
However, in part 3, the program does not play well. I used a 4 points perspective transformation from opencv, the 4 points is calculated by the horizontal lines. Sometimes it was OK for the result, most time it was not.
Is there any way I can do a transform to make horizontal lines more parallel?
Like the auto perspective correction in this photoshop tutorial:
https://www.youtube.com/watch?v=TnnIaCWRQDM
I googled for a long time and did not find the algorithm behind. Please help if you have any idea, many thanks.