Automatic perspective correction OpenCV

后端 未结 2 1136
面向向阳花
面向向阳花 2020-11-27 10:47

I am trying to implement Automatic perspective correction in my iOS program and when I use the test image I found on the tutorial everything works as expected. But when I ta

2条回答
  •  失恋的感觉
    2020-11-27 11:34

    teethe This typically happens when you rely on somebody else code to solve your particular problem instead of adopting the code. Look at the processing stages and also the difference between their and your image (it is a good idea by the way to start with their image and make sure the code works):

    1. Get the edge map. - will probably work since your edges are fine
    2. Detect lines with Hough transform. - fail since you have lines not only on the contour but also inside of your card. So expect a lot of false alarm lines
    3. Get the corners by finding intersections between lines. - fail for the above mentioned reason
    4. Check if the approximate polygonal curve has 4 vertices. - fail
    5. Determine top-left, bottom-left, top-right, and bottom-right corner. - fail
    6. Apply the perspective transformation. - fail completely

    To fix your problem you have to ensure that only lines on the periphery are extracted. If you always have a dark background you can use this fact to discard the lines with other contrasts/polarities. Alternatively you can extract all the lines and then select the ones that are closest to the image boundary (if your background doesn't have lines).

提交回复
热议问题