Results 1 to 7 of 7

Thread: [OpenCV]Seg fault

  1. #1
    Join Date
    Apr 2013
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Thumbs up [OpenCV]Seg fault

    Hello, I would like to compile a simple OpenCV application in Qt.

    I already looked at Qt-OpenCV-simple-example topic but its too complicated for me at the moment. I followed a great tutorial on YouTube.
    Unfortunately I can't get it working, that's why I'm asking for help.

    Miscellaneous information :
    Ubuntu 13.04 (64 bits)

    Qt Creator 2.7.0
    Qt framework 5.0.1 (64 bits)

    OpenCV 2.4.4
    Qt Code:
    1. rc libopencv-calib3d2.3 2.3.1-11ubuntu2 amd64 computer vision Camera Calibration library
    2. ii libopencv-calib3d2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision Camera Calibration library
    3. rc libopencv-contrib2.3 2.3.1-11ubuntu2 amd64 computer vision contrib library
    4. rc libopencv-core2.3 2.3.1-11ubuntu2 amd64 computer vision core library
    5. ii libopencv-core2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision core library
    6. rc libopencv-features2d2.3 2.3.1-11ubuntu2 amd64 computer vision Feature Detection and Descriptor Extraction library
    7. ii libopencv-features2d2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision Feature Detection and Descriptor Extraction library
    8. rc libopencv-flann2.3 2.3.1-11ubuntu2 amd64 computer vision Clustering and Search in Multi-Dimensional spaces library
    9. ii libopencv-flann2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision Clustering and Search in Multi-Dimensional spaces library
    10. rc libopencv-gpu2.3 2.3.1-11ubuntu2 amd64 computer vision GPU Processing library
    11. rc libopencv-highgui2.3 2.3.1-11ubuntu2 amd64 computer vision High-level GUI and Media I/O library
    12. ii libopencv-highgui2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision High-level GUI and Media I/O library
    13. rc libopencv-imgproc2.3 2.3.1-11ubuntu2 amd64 computer vision Image Processing library
    14. ii libopencv-imgproc2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision Image Processing library
    15. rc libopencv-legacy2.3 2.3.1-11ubuntu2 amd64 computer vision legacy library
    16. ii libopencv-legacy2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision legacy library
    17. rc libopencv-ml2.3 2.3.1-11ubuntu2 amd64 computer vision Machine Learning library
    18. ii libopencv-ml2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision Machine Learning library
    19. rc libopencv-objdetect2.3 2.3.1-11ubuntu2 amd64 computer vision Object Detection library
    20. ii libopencv-objdetect2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision Object Detection library
    21. rc libopencv-video2.3 2.3.1-11ubuntu2 amd64 computer vision Video analysis library
    22. ii libopencv-video2.4 2.4.2+dfsg-0exp2ubuntu1 amd64 computer vision Video analysis library
    To copy to clipboard, switch view to plain text mode 

    The Youtube tutorial is for Windows, I modified the .pro file and it looks like this :

    Qt Code:
    1. QT += core gui
    2.  
    3. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    4.  
    5. TARGET = QtTracker3
    6. TEMPLATE = app
    7.  
    8.  
    9. SOURCES += main.cpp\
    10. dialog.cpp
    11.  
    12. HEADERS += dialog.h
    13.  
    14. FORMS += dialog.ui
    15.  
    16.  
    17. # Show Qt where OpenCV is :
    18. INCLUDEPATH += /usr/local/include/opencv #/usr/local/include/opencv2
    19.  
    20. LIBS += -L/usr/local/lib \
    21. -lopencv_calib3d \
    22. -lopencv_contrib \
    23. -lopencv_core \
    24. -lopencv_features2d \
    25. -lopencv_flann \
    26. -lopencv_gpu \
    27. -lopencv_highgui \
    28. -lopencv_imgproc \
    29. -lopencv_legacy \
    30. -lopencv_ml \
    31. -lopencv_objdetect \
    32. -lopencv_ts \
    33. -lopencv_video
    To copy to clipboard, switch view to plain text mode 

    The project builds successfuly but the program exits at start.

    Qt Code:
    1. Debugging starts
    2. &"warning: GDB: Failed to set controlling terminal: Ioctl() inappropr\303\251 pour un p\303\251riph\303\251rique\n"
    3. no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. 0 ?? /usr/lib/x86_64-linux-gnu/libQtTest.so.4 0x7fffeff97d3c
    2. 1 ?? /lib64/ld-linux-x86-64.so.2 0x7ffff7de9876
    3. 2 ?? /lib64/ld-linux-x86-64.so.2 0x7ffff7de9930
    4. 3 ?? /lib64/ld-linux-x86-64.so.2 0x7ffff7ddb68a
    5. 4 ?? 0x1
    6. 5 ?? 0x7fffffffe920
    7. 6 ??
    To copy to clipboard, switch view to plain text mode 

    The arrow points this line
    Qt Code:
    1. 0x7fffeff97d3c <+0x0000> lock incl (%rbx)
    To copy to clipboard, switch view to plain text mode 

    The whole project is enclosed in this post (QtTest_Vic.zip). Thanks in advance for your precious help

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: [OpenCV]Seg fault

    Miscellaneous information :
    Ubuntu 13.04 (64 bits)

    Qt Creator 2.7.0
    Qt framework 5.0.1 (64 bits)
    0 ?? /usr/lib/x86_64-linux-gnu/libQtTest.so.4 0x7fffeff97d3c
    You claim to be using Qt5 but the program is clearly linked, or wanting to link, against Qt4. Your PRO file does not indicate that you are building a QTestLib test and yet your error output (is that a stack trace?) directly references it.

    At the very least you need to do a clean build and make sure you use the correct QMake version and the program is run in an environment where the matching Qt version libraries can be found. If the pre-packaged OpenCV is dependent on Qt4 then you will need to use Qt4 or rebuild your own OpenCV.

  3. #3
    Join Date
    Apr 2013
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Lightbulb Re: [OpenCV]Seg fault

    NB : The enclosed file in the first post is wrong, this is the good one : QtTracker3_TheGoodOne.zip
    Thanks for your reply. I switched to my Ubuntu 12.04 to simplify the problem.

    So now the config is :
    Qt Creator 2.4.1
    Qt framework 4.8.0 (64 bits)

    I built my own OpenCV 2.4.4a with the following CMAKE :
    Qt Code:
    1. cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_FFMPEG=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
    To copy to clipboard, switch view to plain text mode 

    I deleted the .pro.user file and launched the .pro file. Qt gave me no other option than "Desktop"
    When I try to compile I get the following errors :

    Qt Code:
    1. 22:41:05: Exécution des étapes de compilation pour le projet QtTracker3...
    2. 22:41:05: Configuration inchangée, étape QMake sautée.
    3. 22:41:05: Débute : "/usr/bin/make" -w
    4. make: Entering directory `/home/victor/Documents/Projets/FZ200/QtTracker3'
    5. /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -o Makefile QtTracker3.pro
    6. make: Leaving directory `/home/victor/Documents/Projets/FZ200/QtTracker3'
    7. make: Entering directory `/home/victor/Documents/Projets/FZ200/QtTracker3'
    8. g++ -Wl,-O1 -o QtTracker3 main.o dialog.o moc_dialog.o -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgproc /usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so -lQtGui -lQtCore -lpthread
    9. /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprint_finalize@LIBAVUTIL_51'
    10. /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_make_smpte_tc_string@LIBAVUTIL_51'
    11. /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_make_string@LIBAVUTIL_51'
    12. /usr/local/lib/libavcodec.so.54: undefined reference to `av_realloc_f@LIBAVUTIL_51'
    13. /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_get_smpte_from_framenum@LIBAVUTIL_51'
    14. make: Leaving directory `/home/victor/Documents/Projets/FZ200/QtTracker3'
    15. /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_init@LIBAVUTIL_51'
    16. /usr/local/lib/libavcodec.so.54: undefined reference to `av_samples_set_silence@LIBAVUTIL_51'
    17. /usr/local/lib/libavcodec.so.54: undefined reference to `av_calloc@LIBAVUTIL_51'
    18. /usr/local/lib/libavcodec.so.54: undefined reference to `av_get_media_type_string@LIBAVUTIL_51'
    19. /usr/local/lib/libavformat.so.54: undefined reference to `av_dynarray_add@LIBAVUTIL_51'
    20. /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprint_init@LIBAVUTIL_51'
    21. /usr/local/lib/libavcodec.so.54: undefined reference to `av_asprintf@LIBAVUTIL_51'
    22. /usr/local/lib/libavcodec.so.54: undefined reference to `av_timecode_make_mpeg_tc_string@LIBAVUTIL_51'
    23. /usr/local/lib/libavformat.so.54: undefined reference to `av_rescale_q_rnd@LIBAVUTIL_51'
    24. /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprintf@LIBAVUTIL_51'
    25. /usr/local/lib/libavcodec.so.54: undefined reference to `av_samples_copy@LIBAVUTIL_51'
    26. /usr/local/lib/libavcodec.so.54: undefined reference to `av_get_default_channel_layout@LIBAVUTIL_51'
    27. /usr/local/lib/libavcodec.so.54: undefined reference to `av_timecode_init_from_string@LIBAVUTIL_51'
    28. /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprint_chars@LIBAVUTIL_51'
    29. /usr/local/lib/libavcodec.so.54: undefined reference to `av_timecode_adjust_ntsc_framenum@LIBAVUTIL_51'
    30. /usr/local/lib/libavcodec.so.54: undefined reference to `av_tempfile@LIBAVUTIL_51'
    31. collect2: ld returned 1 exit status
    32. make: *** [QtTracker3] Error 1
    33. 22:41:05: Le processus "/usr/bin/make" s'est terminé avec le code 2.
    34. Erreur à la compilation du projet QtTracker3 (cible : Desktop)
    35. Lors de l'exécution de l'étape "Make""
    To copy to clipboard, switch view to plain text mode 

    I did not find much answers for this problem on the web :
    Osman Eralp
    September 12, 2012 at 10:38 am · Reply

    You would get an undefined reference if you forgot to include the include paths in the g++ command. Please use this syntax:
    g++ `pkg-config opencv --cflags` my_code.cpp -o my_code `pkg-config opencv --libs`

    Let me know if you still are having problems.
    How do I do the equivalent in Qt ? I tried by adding the following two lines in the .pro file :
    Qt Code:
    1. CONFIG += link_pkgconfig
    2. PKGCONFIG += opencv
    To copy to clipboard, switch view to plain text mode 

    I really appreciate your help

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [OpenCV]Seg fault

    Quote Originally Posted by Vicolaships View Post

    How do I do the equivalent in Qt ? I tried by adding the following two lines in the .pro file :
    Qt Code:
    1. CONFIG += link_pkgconfig
    2. PKGCONFIG += opencv
    To copy to clipboard, switch view to plain text mode 

    I really appreciate your help
    http://qt-project.org/doc/qt-4.8/qma...ect-files.html
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: [OpenCV]Seg fault

    Your program is expecting to be linked against libavutil also; is it on your machine?

    The code you posted builds just fine on my machine.

  6. #6
    Join Date
    Apr 2013
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Arrow Re: [OpenCV]Seg fault

    Hello,

    Here are my libav* libraries :
    Qt Code:
    1. /usr/local/lib$ ls -al libavcodec*
    2. -rw-r--r-- 1 root root 90588642 mars 25 15:32 libavcodec.a
    3. lrwxrwxrwx 1 root root 23 mars 25 15:32 libavcodec.so -> libavcodec.so.54.23.100
    4. lrwxrwxrwx 1 root root 23 mars 25 15:32 libavcodec.so.54 -> libavcodec.so.54.23.100
    5. -rwxr-xr-x 1 root root 7527520 mars 25 15:32 libavcodec.so.54.23.100
    6. lrwxrwxrwx 1 root root 22 mars 24 15:12 libavcodec.so.55 -> libavcodec.so.55.1.100
    7. -rwxr-xr-x 1 root root 7692608 mars 24 15:12 libavcodec.so.55.1.100
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. /usr/local/lib$ ls -al libavformat*
    2. -rw-r--r-- 1 root root 22319750 mars 25 15:32 libavformat.a
    3. lrwxrwxrwx 1 root root 23 mars 25 15:32 libavformat.so -> libavformat.so.54.6.100
    4. lrwxrwxrwx 1 root root 23 mars 25 15:32 libavformat.so.54 -> libavformat.so.54.6.100
    5. -rwxr-xr-x 1 root root 1192224 mars 25 15:32 libavformat.so.54.6.100
    6. lrwxrwxrwx 1 root root 23 mars 24 15:12 libavformat.so.55 -> libavformat.so.55.0.100
    7. -rwxr-xr-x 1 root root 1455456 mars 24 15:12 libavformat.so.55.0.100
    To copy to clipboard, switch view to plain text mode 

    I tried to run sudo apt-get update && sudo apt-get upgrade but it didn't solve the problem.
    I guess my version of livav* is wrong, which one should I use ?

  7. #7
    Join Date
    Apr 2013
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Thumbs up Re: [OpenCV]Seg fault

    After a new installation of Ubuntu 13.04 and installation of OpenCV using :
    Qt Code:
    1. sudo apt-get install -y libopencv-dev libcv-dev libhighgui-dev
    To copy to clipboard, switch view to plain text mode 

    The project compiles /run fine.

    Problem solved

Similar Threads

  1. Trying to use OpenCV
    By danilodsp in forum Newbie
    Replies: 6
    Last Post: 18th August 2011, 09:41
  2. OpenCV on mac
    By sandeep_hyd123 in forum Newbie
    Replies: 1
    Last Post: 17th June 2011, 05:53
  3. Qt and OpenCV
    By malorie in forum Newbie
    Replies: 2
    Last Post: 7th March 2010, 15:57
  4. JAI vs. OpenCV vs. ITK
    By tpieciak in forum General Programming
    Replies: 0
    Last Post: 8th July 2009, 14:45
  5. OpenCv + Qt
    By Janderson Borges in forum Qt Programming
    Replies: 3
    Last Post: 2nd December 2008, 14:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.