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!
- Are the lines in perfect vertical or horizontal directions? (0 degree or 90 degree?)cxyzs7– cxyzs72013-05-28 04:11:27 +00:00Commented 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.cxyzs7– cxyzs72013-05-31 05:59:49 +00:00Commented May 31, 2013 at 5:59
Add a comment |
1 Answer
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
1 Comment
tihuBird
jspal, the code show the how to get edge but not get edge line.