Closed pdeman closed 4 years ago
Build with debug information, run under gdb
and provide stracktrace dump.
I didn't know gdb can be used with python. I am installing it. and I am compiling opencv in debug mode. but how can I specify python to use opencv "debug" or "release" ? for now I did this py file.
import cv2
src = cv2.imread("/SSD/corridor.jpg", cv2.IMREAD_COLOR)
gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
lsd = cv2.LineSegmentDetector()
fld = cv2.ximgproc_FastLineDetector()
lines_lsd = lsd.detect(gray)
I do
gdb python3
run testLineSegmentDetector.py
and I get :
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New Thread 0x7f845c11f0 (LWP 18624)]
[New Thread 0x7f83dc01f0 (LWP 18625)]
[New Thread 0x7f835bf1f0 (LWP 18626)]
[New Thread 0x7f82dbe1f0 (LWP 18627)]
[New Thread 0x7f825bd1f0 (LWP 18628)]
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x0000007fb6060308 in pyopencv_cv_LineSegmentDetector_detect(_object*, _object*, _object*) ()
from /usr/local/lib/python3.6/dist-packages/cv2/python-3.6/cv2.cpython-36m-aarch64-linux-gnu.so
I don't know if it used opencv release or debug build.
@pdeman
lsd = cv2.LineSegmentDetector()
does not create a valid object ! instead you would have to call createLineSegmentDetector() to create an instance, which unfortunately will throw:
cv2.error: OpenCV(4.5.0-pre) C:\p\opencv\modules\imgproc\src\lsd.cpp:143: error: (-213:The function/feature is not implemented) Implementation has been removed due original code license issues in function 'LineSegmentDetectorImpl'
so, currently, you cannot use LSD at all ;(
apart from that, it's a similar problem to:
o = cv2.ORB() # must be cv2.ORB_create()
o.detect(np.ones((100,100,3),np.uint8))
(segfaults, dereferencing the self pointer)
imho, it's a bug, that we are able to call python constructors like that.
p.s: at least createFastLineDetector() seems to work as expected..
@berak is right.
cv.LineSegmentDetector() cv.FastLineDetector()
Both classes are "abstract" and should not be used (work) in this way. Looks like python binding generator doesn't handle them properly.
You should use createFastLineDetector()
instead.
BTW, LSD implementation was removed from OpenCV due to license issues.
ok thanks. the fastlinedetector is working. too bad for lsd, i had better results with it. I guess the license problem is not related to python. If have try to use LSD using c++ that will be the same.
I am using a jetson tx2, base jetpack 32, ubuntu 18.04 I installed OpenCV => 4.3 including opencv-contrib following this:
when I do cv2.getBuildInformation() from python:
and then I python3 I do:
this works. but when I do :
lines_lsd = lsd.detect(gray)
orlines_fld = fld.detect(gray);
both generates a segmentation fault and I don't know why.