Any implementation of LineSegmentDetector for python ?

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

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 -0500 )edit

@ilas. Can you post ur code?

supra56 gravatar imagesupra56 ( 2019-07-17 06:53:11 -0500 )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 -0500 )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 -0500 )edit

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

supra56 gravatar imagesupra56 ( 2019-07-17 07:59:47 -0500 )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 -0500 )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 -0500 )edit