Skip to content

Vanishing Point detection for images and videos using Least Squares in C++

License

Notifications You must be signed in to change notification settings

ankitdhall/Vanishing-Point-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Vanishing Point Detection using Least Squares

Detector on sample footage.
Red colored lines were considered for estimating the vanishing point. The black circle marks the region of interest, where the center of the circle is the approximate vanishing point.

  1. Dependencies
  2. Speed
  3. Algorithm

Citing Vanishing-Point-Detector

Please cite our work if Vanishing-Point-Detector and our approach helps your research.

@Misc{Vanishing-Point-Detector,
  author = {{Dhall*}, A. and {Chandak*} Y.}
  title = "{Vanishing Point Detection using Least Squares}",
  howpublished = {\url{https://github.com/ankitdhall/Vanishing-Point-Detector}},
  year = {2015}
}

Dependencies

  • OpenCV for C++
  • Armadillo

Speed

Average performance: 21 fps

Algorithm

  • The algorithm starts by computing dx and dy of the image. Then the edge vectors are formed which encodes the direction and magnitude at each pixel.

  • This field is segmented into connected regions of pixels that share the same vector direction up to a certain tolerance.

  • The principal axis of the bounding box enclosing this region gives a single pixel thick straight line. Then, x, y co-ordinates of either ends are stored.

  • Then the lines are converted to the ax + by = c form.

  • These co-efficients (a, b, c) are stored in the matrix A, B in the following format:

     A = [a1 b1  
          a2 b2  
            ..  
            ..  
         an bn]    
     B = [c1 c2 ... cn ]'  
  • Solve for vector X in AX = B with the concept of least square approximation of the answer. Where X = [x y] T

  • For each pair of lines in the matrix A, their point of intersection X’ = [x y] T is found. This is multiplied with the matrix A and then B is subtracted to get the error vector E.

    E = AX’ – B
  • The squared sum of error vector is computed and whichever X’ gave the least summation of errors is chosen as the vanishing point in the image.