Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV Identifying Lines and Curves

I'm just starting to learn OpenCV programming. May I just ask about how can I identify lines and curves in OpenCV? My problem is that I have to identify if the image contains a convex or concave (horizontal or vertical curve) curve, a vertical, diagonal or a horizontal line.

In my code, I used CvSetImageROI to take a particular part of an image, and then I'm trying to identify each according to the said lines/curves.

Are there functions in OpenCV that are available? Thank you very much for the help. By the way, i'm using Linux and C++.

like image 328
cmsl Avatar asked Nov 08 '11 07:11

cmsl


People also ask

What algorithm is used to detect lines in OpenCV?

The Hough Transform is a method that is used in image processing to detect any shape, if that shape can be represented in mathematical form. It can detect the shape even if it is broken or distorted a little bit.

How do you find a curved line?

The Hough Transform (HT) is a popular technique for detecting straight lines and curves on gray-scale images. It maps image data from image space to a parameter space, where curve detection becomes peak detection problem.

How do we detect edges of items in a drawing in OpenCV?

OpenCV provides many edge-finding filters, including Laplacian(), Sobel(), and Scharr(). These filters are supposed to turn non-edge regions to black, while turning edge regions to white or saturated colors. However, they are prone to misidentifying noise as edges.

How do you detect lines?

In a convolution-based technique, the line detector operator consists of a convolution masks tuned to detect the presence of lines of a particular width n and a θ orientation. Here are the four convolution masks to detect horizontal, vertical, oblique (+45 degrees), and oblique (−45 degrees) lines in an image.


1 Answers

Hough transform http://en.wikipedia.org/wiki/Hough_transform, http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm is the standard way to do it. In its simple form (as implemented in OpenCV) it can detect lines of arbitray position and angle and line segments.

Look here for an example http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=hough#houghlinesp

For curves, the detection process is a bit more complicated, and you need the general Hough transform It is not yet available in OCV, but you can write it as an exercise or look for a good implementation. http://en.wikipedia.org/wiki/Generalised_Hough_transform describes it (in short)

like image 135
Sam Avatar answered Jan 14 '23 17:01

Sam