Two versions of opencv-python, ver. 3.4.5.20 (Python 2.7.18) and ver. 4.11.0.86 (Python 3.12.0) were used for line segment detection
Both version of opencv-python implements the following paper (algorithm):
Rafael Grompone von Gioi, Jérémie Jakubowicz, Jean-Michel Morel, and Gregory Randall. Lsd: a line segment detector. 2012.
Proof:- LSD for ver. 3.4.5 LSD for ver. 4.11.0
One of the examples in which the number of lines detected for the same grayscale image, is different, is for the following gray_scale image:- Grayscale values for 512x512 image
Or use the grayscale image: (dropbox link)
For this image the opencv-python ver. 3.4.5.20 detects 176 lines and ver. 4.11.0.86 detects 177 lines.
Code that was used for both version.
import cv2
import numpy
lsd = cv2.createLineSegmentDetector(0)
lines = lsd.detect(np.array(gray))
To recreate, the value of file can be simply assigned to the gray as:-
gray = lsd.detect( copy paste the content of the file here)
To check the number of lines:
print(len(lines[0]))
Is there a way or a workaround so that the output of lsd.detect of ver. 3.4.5 is replicated to ver. 4.11.0.86 ?
Purpose of replication of result: An application backend was originally written in Python 2.7 and now needs to be rewritten in Python 3.12. I need to replicate the results, but because the number of line segments is different, I am unable to do so.
