Ask Your Question
0

line extration in opencv_contrib

asked 2015-09-07 21:33:02 -0600

Sheng Liu gravatar image

updated 2015-09-07 21:36:39 -0600

I need detect lines in a image. And I find the line_extraction methods in opencv_contrib. But related cpp files in opencv_contrib cannot be compiled correctly. What should I do? Apart from Hough Transfom, could you recommend some good methods to detect lines? Thanks.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
5

answered 2015-09-08 00:38:17 -0600

berak gravatar image

updated 2015-09-08 01:03:07 -0600

did you mean the line_descriptor module in the contrib repo ? this is probably the wrong tool anyway, it's for feature2d extraction with lines, similar to ORB or SIFT.

if you just need line segments, you might try the LineSegmentDetector (which also delivers the base for above descriptor class) have a look at the sample, too !

edit flag offensive delete link more

Comments

1

Thank you!

Sheng Liu gravatar imageSheng Liu ( 2015-09-08 06:17:31 -0600 )edit

I bought a tank model in a supermarket. Now I intend to detect gun barrel by LineSegmentDetector. But I have two issues. Firstly the edge lines of the tank and other uncorrelated lines are all detected. It is difficult to distinguish the edge lines of gun barrel. Secondly the detection result of LineSegmentDetector are not stright lines but many short lines. Could you give me some advice?

Sheng Liu gravatar imageSheng Liu ( 2015-09-13 06:52:47 -0600 )edit

"detection result of LineSegmentDetector are not stright lines but many short lines" - yes, that's true. so, maybe it's the wrong tool for your job. if you still want to detect lines, have a look at HoughLines which will compute 'inifinite' lines, or HoughLinesP which will result in segments, too, but at least longer ones.

then, there's some doubt, if finding lines it the right idea at all. maybe findContours ?

berak gravatar imageberak ( 2015-09-13 07:02:51 -0600 )edit

Thanks for your help! The input of findContours is a binary image. Do you mean threshod the gray image? But the part of gun barrel may disappear in the process of threshoding.

Sheng Liu gravatar imageSheng Liu ( 2015-09-13 07:23:38 -0600 )edit

The edge of gun barrel are two parallel lines. How about using HoughLines to detect lines of which slope are similar and distance satisfy a certain condition?

Sheng Liu gravatar imageSheng Liu ( 2015-09-13 07:46:07 -0600 )edit

if your barrel has a clear contrast to the bg, threshold() will do fine. Sobel() and Canny() are alternative ways.

berak gravatar imageberak ( 2015-09-13 07:56:44 -0600 )edit

Could you tell me how to adjust the parameters to make the LineSegmentDetector output stright lines or shorter lines?

Sheng Liu gravatar imageSheng Liu ( 2015-09-14 09:19:20 -0600 )edit

sample runs fine even on vs2008 here, what was the problem on your side ?

i did not write the lsd code, but i guess, the main purpose of it is to find very short pieces (that allow to get a gradient /orientation from this) . i don't see any way to make them longer. again, you're probably looking at the wrong tool. (yes, it's far easier to use, than HuoghLines, but again, very restricted)

berak gravatar imageberak ( 2015-09-14 09:31:40 -0600 )edit

After delete the Canny(image, image, 50, 200, 3); // Apply canny edge, I find the sample run well in VS13 but it cannot work well in VS12.

Sheng Liu gravatar imageSheng Liu ( 2015-09-14 09:42:09 -0600 )edit

Thanks for your help!

Sheng Liu gravatar imageSheng Liu ( 2015-09-14 09:52:03 -0600 )edit
1

answered 2015-09-16 00:29:55 -0600

Sheng Liu gravatar image

updated 2015-09-16 00:35:54 -0600

Thanks to berak and 逸风, I find the LineSegmentDetector provided by this have a better result than LineSegmentDetector. The former output straight lines!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-09-07 21:33:02 -0600

Seen: 716 times

Last updated: Sep 16 '15