0

I am trying to make a lot of building images' horizontal perspective corrected. like this: from google search My plan was:

  1. detect all long straight;
  2. find the nearly horizontal lines;
  3. 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.

Lucylalalala
  • 313
  • 2
  • 10
  • I don't see any problem with your approach. Maybe you can make another question with the part of the code that is not working the way you desire. Do you have only one image or a video? I only ask because there if it is a video, you can use 2 frames as stereo images and use the epipolar constraint. – Fred Guth Jun 19 '18 at 02:43
  • May be this will help(same concept) : https://stackoverflow.com/questions/10196198/how-to-remove-convexity-defects-in-a-sudoku-square https://www.pyimagesearch.com/2014/08/25/4-point-opencv-getperspective-transform-example/ – Pygirl Jun 19 '18 at 05:19

1 Answers1

0

It's not clear what exactly you're doing. If you're not doing this already, you could detect the intersection points of the two horizontal and two vertical lines, then you have the 4 points you need.

fireant
  • 14,080
  • 4
  • 39
  • 48