Ask Your Question

Revision history [back]

You can use the Hough transform to detect straight lines in the frame. Once the main lines are found, and seems it would work pretty good according to your second picture, the angles can be postprocessed. Note that the Hough operation ("transform"), same as cvFindContours, will return loads of straight lines in the picture, unwanted ones should be filtered out via line size.

There is this full tutorial in openCV with code included: http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html.

You can use the Hough transform to detect straight lines in the frame. Once the main lines are found, and seems it would work pretty good according to your second picture, the angles can be postprocessed. Note that the Hough operation ("transform"), same as cvFindContours, ("transform") will return loads of straight lines of different lenght in the picture, unwanted ones should be filtered out via line size.

There is this full tutorial in openCV with code included: http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html.