Ask Your Question
0

Any implementation of LineSegmentDetector for python ?

asked 2019-07-17 01:57:57 -0600

ilas gravatar image

I see that cv2.createLineSegmentDetector implementation has been removed due original code license issues in function, any workarounds that don't include downgrading to an older version ?

Thanks a lot!

edit retag flag offensive close merge delete

Comments

Yes. cv2.createLineSegmentDetector is still there OpenCV 4.1.x. I am using OpenCV 4.1.1. Raspberry pi 4B, Buster Ver 10

supra56 gravatar imagesupra56 ( 2019-07-17 06:52:09 -0600 )edit

@ilas. Can you post ur code?

supra56 gravatar imagesupra56 ( 2019-07-17 06:53:11 -0600 )edit

I tried something very simple, just to give a first look :

img = cv2.imread("messigray.jpg",0)
lsd = cv2.createLineSegmentDetector(0)
lines = lsd.detect(img)[0] #Position 0 of the returned tuple are the detected lines
drawn_img = lsd.drawSegments(img,lines)
cv2.imshow("LSD",drawn_img )
cv2.waitKey(0)
ilas gravatar imageilas ( 2019-07-17 07:15:21 -0600 )edit

My apologized. You were right. My co-worker found problem.. implementation has been removed due original code license issues in function. It doesn't work on OpenCV 4.1.x. I then switched to OpenCV 3.X and it should work too.

supra56 gravatar imagesupra56 ( 2019-07-17 07:55:44 -0600 )edit

@ilas. I tried your code in OpenCV 3.x and it worked too.

supra56 gravatar imagesupra56 ( 2019-07-17 07:59:47 -0600 )edit

I see. Well, I wouldn't like to change versions cause I need the newest in other parts of the projet. Thank you anyway !

ilas gravatar imageilas ( 2019-07-17 08:06:17 -0600 )edit
1

I think you can use instead the Fast line detector. There is a sample.

Eduardo gravatar imageEduardo ( 2019-07-17 08:08:07 -0600 )edit

As Line Segment Detector has been removed due to license conflict, I suggest you all add a thumbs-up to this issue!
"Restore LineSegmentDetector LSD & avoid license conflict": https://github.com/opencv/opencv_cont...

ruelj2 gravatar imageruelj2 ( 2020-05-09 14:29:17 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-12-22 08:50:23 -0600

supra56 gravatar image

updated 2019-12-22 08:51:42 -0600

ATTENTION: Fast Line Detector which is available in OpenCV 4.x.x.

import cv2
img = cv2.imread("box.jpg", 0)

fld = cv2.ximgproc.createFastLineDetector()
lines = fld.detect(img)

result_img = fld.drawSegments(img,lines)

cv2.imshow("Result",  result_img)
cv2.waitKey(0)
edit flag offensive delete link more

Comments

Note: it's available in OpenCV 3.4.x too.

lapis gravatar imagelapis ( 2020-01-13 04:41:56 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-07-17 01:57:57 -0600

Seen: 8,336 times

Last updated: Dec 22 '19