1

How to detect vertical and horizontal lines ? i know opencv provide the function based on hough transform to detect all direction lines,but it`s low_performance to compute all direction lines because i just want to dectect Ver and Hon lines .Any suggestion, thanks!

2
  • Are the lines in perfect vertical or horizontal directions? (0 degree or 90 degree?) Commented May 28, 2013 at 4:11
  • You can modify OpenCV's HoughTransform code so that every point on the edge only votes to limited degrees (e.g. 0 +- 5 and 90 +- 5), this way you should get 180/20 = 9X speed-up. Given you need smaller memory to hold Hough space, the actually speed-up would be bigger than 9X. Commented May 31, 2013 at 5:59

1 Answer 1

3

HoughLinesP is the easiest approach. You can filter out the angles that aren't horizontal or vertical.

However, if you want to use a potentially faster approach that only detects certain angles, you can try cv::Sobel. There's some sample code here that detects vertical and horizontal edges:

http://subversion.assembla.com/svn/CoffeeWatcher/trunk/ImageUtils.cpp

Sign up to request clarification or add additional context in comments.

1 Comment

jspal, the code show the how to get edge but not get edge line.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.