-2

I've found other questions on the topic of detecting straight lines in images which I will read up on.

But I'm aware the in many photos the real life straight lines end up curved.

I don't have to de-curve fish-eye distortion or anything extreme.

But I would like to handle a "typical" amount of curve distortion as though they are still straight lines.

Are there some algorithms or techniques that can handle this in a "good enough" manner?

Here's an old photo of mine of a book showing the kind of curved straight lines I had in mind. It's a good example for the curvature and lens distortion. (It may not be a good example generally due to the other lines in the background, but that's beside the point of the current question.)

Turkish Gabo

hippietrail
  • 15,848
  • 18
  • 99
  • 158
  • 1
    If you know the intrinsic camera parameters, or can get them, then you can perform [lens distortion correction](https://en.wikipedia.org/wiki/Distortion_(optics)#Software_correction) which makes straight lines straight again. Often times just solving for the radial distortion is sufficient. OpenCV has a [camera calibration](http://docs.opencv.org/2.4/doc/tutorials/calib3d/camera_calibration/camera_calibration.html) tool which describes the procedure of obtaining these parameters in more detail. This procedure is called camera calibration. – jodag Aug 08 '17 at 05:14
  • 1
    Also, if you know the lens used to collect the image, then [LensFun](http://lensfun.sourceforge.net/lenslist/) is a tool which has pre-computed models for many commercial lenses. – jodag Aug 08 '17 at 05:18
  • 1
    Moderately distorted lines will keep being detected by Hough. But you should show us typical images. –  Aug 14 '17 at 15:50
  • @YvesDaoust: Example added! Thanks for the feedback. – hippietrail Aug 15 '17 at 00:10

2 Answers2

2

The curvature of the edges doesn't seem that severe, and at worst the Hough transform will just break the edges in a few segments.

I would be more worried by the lack of contrast of the edges (white on white) which can make the detection fail.

  • As noted this was just a random pic I chose for the curvature, which is worse than I expect in the typical case. Other problems with this specific image are not important for the question since the real problem will be dealing with many varied images of flat rectangular objects. – hippietrail Aug 15 '17 at 23:45
  • When I am asking for a typical image, I am not asking for a random one. I know what distortion is. I don't know about your case. –  Aug 16 '17 at 06:41
0

As it turns out, one of the most popular techniques used for straight line detection also exists in versions that work with curves.

It's called the "Hough Transform".

It was originally for detecting straight lines, but has been generalized to also work with curves and other arbitrary shapes. From the Wikipedia article:

The classical Hough transform was concerned with the identification of lines in the image, but later the Hough transform has been extended to identifying positions of arbitrary shapes, most commonly circles or ellipses.

There are even papers on the specific topic of using Hough transforms to deal with lens distortion:

hippietrail
  • 15,848
  • 18
  • 99
  • 158