Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are a couple of ways to do this in OpenCV. All have different strengths.

One is contours. You've already tried this, and found the problems. On the plus side, it's pretty fast and usually very accurate.

Second is HoughLinesP. This uses the Hough transform to find lines in the image. It takes a canny edge detected image as input, and outputs a set of lines. It's slower than most everything else, and has problems with angular resolution. In your case, with one image, and only a few typical angles, this should be great.

Third is the Line Segment Detector. I haven't used this too much, so I'm not quite sure of the tradeoffs. It is much faster than HoughLines, but not as fast (I think) as contours. I'm also not sure how to use it. You'd have to look at the samples. It might actually be more accurate than the others though.