Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV when creating a Detector #21

Closed
Pravez opened this issue Jul 17, 2018 · 3 comments
Closed

SIGSEGV when creating a Detector #21

Pravez opened this issue Jul 17, 2018 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@Pravez
Copy link

Pravez commented Jul 17, 2018

Hi !
First, thank you for your work !

I was first using the darknet python script, but with really poor performances. As yours seems better I am trying to use it but get a segfault each time I try to instantiate a Detector.

I have first installed your lib through PyPi, but it did not work. Then building it from source with my own build of Darknet, was successful when installing, but not working on execution, with always a segfault error. Apparently after running valgrind it may concern memory allocation ...

 Access not within mapped region at address 0x0
==18723==    at 0x16254939: free_network (in /home/pbreton/.local/lib/python3.6/site-packages/__libdarknet/libdarknet.so)
==18723==    by 0x15FE2FF8: __pyx_pf_9pydarknet_8Detector_6__dealloc__ (pydarknet.cpp:3157)
==18723==    by 0x15FE2FF8: __pyx_pw_9pydarknet_8Detector_7__dealloc__ (pydarknet.cpp:3142)
==18723==    by 0x15FE2FF8: __pyx_tp_dealloc_9pydarknet_Detector(_object*) (pydarknet.cpp:5861)
==18723==    by 0x15FE6FC7: __pyx_tp_new_9pydarknet_Detector(_typeobject*, _object*, _object*) (pydarknet.cpp:5847)
==18723==    by 0x5591FD4: ??? (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x558A64B: _PyObject_FastCallDict (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x5552B41: ??? (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x5522859: _PyEval_EvalFrameDefault (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x5552FC7: PyEval_EvalCodeEx (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x552240B: PyEval_EvalCode (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x55F2213: ??? (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x55F50AD: PyRun_FileExFlags (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x55F5294: PyRun_SimpleFileExFlags (in /usr/lib/libpython3.6m.so.1.0)

Do you have any idea ...?

Also, when building I always have the error (no matter the way I build, seems logical) from ld :
/usr/bin/ld: cannot find -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_photo -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core

while all of my opencv libs are correct and accessible (just compiled darknet manually with it). However, when I enter myself the command line to compile it works. Do you know if python has any problems with rights or paths in order to link C libs ?

Thank you ...

@madhawav
Copy link
Owner

Hi,
Can you let me know the response you get when you run following terminal commands?

pkg-config --cflags opencv
pkg-config --libs opencv

If they say that they cannot find opencv, then there is an issue with your OpenCV installation. Maybe you did not follow the make install step of opencv installation.

@madhawav madhawav self-assigned this Jul 18, 2018
@madhawav madhawav added the question Further information is requested label Jul 18, 2018
@Pravez
Copy link
Author

Pravez commented Jul 18, 2018

Thank you for your answer.
Everything is fine concerning the command line, I checked myself and manually everything works. The pkg-config is successfully returning the correct opencv libs :
-I/usr/include/opencv
-lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_photo -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core

The problem seems to be concerning the way python is accessing the libraries.
But anyway, the problems seems to be resolved by manually executing this line. The installation from source works.

The main problem remains, the segfault when trying to create a Detector

@Pravez
Copy link
Author

Pravez commented Jul 18, 2018

Ok it is truly my fault. I used 3 parameters instead of 4, forgetting that the third is a 0. Thus with 3 bytes as parameters it was logically crashing.

went from

net = Detector(bytes("cfg/yolov3.cfg", encoding="utf-8"), bytes("weights/yolov3.weights", encoding="utf-8"), bytes("cfg/coco.data",encoding="utf-8"))

to

net = Detector(bytes("cfg/yolov3.cfg", encoding="utf-8"), bytes("weights/yolov3.weights", encoding="utf-8"), 0, bytes("cfg/coco.data",encoding="utf-8"))

Thank you for your time,

@Pravez Pravez closed this as completed Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants