2

A segmentation fault occurs when the function cvCreateFileCapture is sometimes invoked using a network URL as argument, for esample: rtsp://IPaddress:Port/Path...

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    ...

    CvCapture* capture = cvCreateFileCapture("rtsp://...");

    ...

    return a.exec();
}

No error occur if the argument is a file on disk.

I build the source code in debug mode and I when the segmentation fault has occurred, the following stack trace is listed:

gst_caps_unref
CvCapture_GStreamer::open(int, char const*)
cvCreateCapture_GStreamer(int, char const*)
cvCreateFileCapture
main

UPDATE. If I create a Plain C++ Project, the call to the function cvCreateFileCapture always results in a segmentation fault. If, instead, I create a Qt Gui Application project, the segmentation fault occurs randomly.

OUTPUT OF VALGRIND

==3160== Memcheck, a memory error detector
==3160== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3160== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3160== Command: ./Calibration 15 8 5 http://root:root@192.168.1.51/axis-cgi/mjpg/video.cgi
==3160== 
--3160-- WARNING: Serious error when reading debug info
--3160-- When reading debug info from /usr/lib/nvidia-331/libGL.so.331.20:
--3160-- Can't make sense of .data section mapping
--3160-- WARNING: Serious error when reading debug info
--3160-- When reading debug info from /usr/lib/nvidia-331/libnvidia-glcore.so.331.20:
--3160-- Can't make sense of .got section mapping
==3160== Invalid read of size 4
==3160==    at 0x74444A2: ??? (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x7446B09: FcConfigFilename (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x745B1EB: FcConfigParseAndLoad (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x7450065: FcInitLoadConfig (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x7450188: FcInitLoadConfigAndFonts (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x745040C: FcInit (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x585B608: ??? (in /usr/lib/i386-linux-gnu/libQtGui.so.4.8.1)
==3160==    by 0x57DCC0B: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (in /usr/lib/i386-linux-gnu/libQtGui.so.4.8.1)
==3160==    by 0x7E014E7: ???
==3160==  Address 0xaaa898c is 20 bytes inside a block of size 22 alloc'd
==3160==    at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==3160==    by 0x7444407: ??? (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x7446B09: FcConfigFilename (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x745B1EB: FcConfigParseAndLoad (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x7450065: FcInitLoadConfig (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x7450188: FcInitLoadConfigAndFonts (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x745040C: FcInit (in /usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4)
==3160==    by 0x585B608: ??? (in /usr/lib/i386-linux-gnu/libQtGui.so.4.8.1)
==3160==    by 0x57DCC0B: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (in /usr/lib/i386-linux-gnu/libQtGui.so.4.8.1)
==3160==    by 0x7E014E7: ???
==3160== 
==3160== 
==3160== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- Y
==3160== starting debugger with cmd: /usr/bin/gdb -nw /proc/3163/fd/1024 3163
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /proc/3163/fd/1024...done.
Attaching to program: /proc/3163/fd/1024, process 3163
Reading symbols from /usr/lib/valgrind/vgpreload_core-x86-linux.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/valgrind/vgpreload_core-x86-linux.so
Reading symbols from /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so
Reading symbols from /usr/local/lib/libopencv_core.so.2.4...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libopencv_core.so.2.4
Reading symbols from /usr/local/lib/libopencv_imgproc.so.2.4...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libopencv_imgproc.so.2.4
Reading symbols from /usr/local/lib/libopencv_highgui.so.2.4...done.
Loaded symbols for /usr/local/lib/libopencv_highgui.so.2.4
Reading symbols from /usr/local/lib/libopencv_calib3d.so.2.4...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libopencv_calib3d.so.2.4
Reading symbols from /usr/lib/i386-linux-gnu/libQtGui.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libQtGui.so.4
Reading symbols from /lib/i386-linux-gnu/libpthread.so.0...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/libpthread-2.15.so...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
done.
Loaded symbols for /lib/i386-linux-gnu/libpthread.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libstdc++.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libstdc++.so.6
Reading symbols from /lib/i386-linux-gnu/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libgcc_s.so.1
Reading symbols from /lib/i386-linux-gnu/libc.so.6...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/libc-2.15.so...done.
done.
Loaded symbols for /lib/i386-linux-gnu/libc.so.6
Reading symbols from /lib/i386-linux-gnu/libz.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libz.so.1
Reading symbols from /lib/i386-linux-gnu/librt.so.1...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/librt-2.15.so...done.
done.
Loaded symbols for /lib/i386-linux-gnu/librt.so.1
Reading symbols from /usr/lib/i386-linux-gnu/libGLU.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libGLU.so.1
Reading symbols from /usr/lib/nvidia-331/libGL.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/nvidia-331/libGL.so.1
Reading symbols from /lib/i386-linux-gnu/libm.so.6...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/libm-2.15.so...done.
done.
Loaded symbols for /lib/i386-linux-gnu/libm.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libjpeg.so.8...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libjpeg.so.8
Reading symbols from /lib/i386-linux-gnu/libpng12.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libpng12.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libtiff.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libtiff.so.4
Reading symbols from /usr/lib/i386-linux-gnu/libjasper.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libjasper.so.1
Reading symbols from /usr/lib/libIlmImf.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libIlmImf.so.6
Reading symbols from /usr/lib/libHalf.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libHalf.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libgstreamer-0.10.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libgstreamer-0.10.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
Reading symbols from /lib/i386-linux-gnu/libglib-2.0.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libglib-2.0.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libgstapp-0.10.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libgstapp-0.10.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libgstvideo-0.10.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libgstvideo-0.10.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libdc1394.so.22...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libdc1394.so.22
Reading symbols from /usr/local/lib/libv4l1.so.0...done.
Loaded symbols for /usr/local/lib/libv4l1.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libxvidcore.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libxvidcore.so.4
Reading symbols from /usr/lib/i386-linux-gnu/libQtOpenGL.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libQtOpenGL.so.4
Reading symbols from /usr/lib/i386-linux-gnu/libQtCore.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libQtCore.so.4
Reading symbols from /usr/lib/i386-linux-gnu/libQtTest.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libQtTest.so.4
Reading symbols from /usr/lib/i386-linux-gnu/libva.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libva.so.1
Reading symbols from /usr/lib/i386-linux-gnu/libvorbisenc.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libvorbisenc.so.2
Reading symbols from /usr/lib/i386-linux-gnu/libvorbis.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libvorbis.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libtheoraenc.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libtheoraenc.so.1
Reading symbols from /usr/lib/i386-linux-gnu/libtheoradec.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libtheoradec.so.1
Reading symbols from /usr/lib/libopencore-amrwb.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libopencore-amrwb.so.0
Reading symbols from /usr/lib/libopencore-amrnb.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libopencore-amrnb.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libmp3lame.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libmp3lame.so.0
Reading symbols from /usr/lib/libfaac.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libfaac.so.0
Reading symbols from /usr/local/lib/libopencv_flann.so.2.4...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libopencv_flann.so.2.4
Reading symbols from /usr/local/lib/libopencv_features2d.so.2.4...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libopencv_features2d.so.2.4
Reading symbols from /usr/lib/i386-linux-gnu/libfontconfig.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libfontconfig.so.1
Reading symbols from /usr/lib/i386-linux-gnu/libaudio.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libaudio.so.2
Reading symbols from /usr/lib/i386-linux-gnu/libfreetype.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libfreetype.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libSM.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libSM.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libICE.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libICE.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libXi.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libXi.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libXrender.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libXrender.so.1
Reading symbols from /usr/lib/i386-linux-gnu/libXext.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libXext.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libX11.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libX11.so.6
Reading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/ld-2.15.so...done.
done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/lib/nvidia-331/tls/libnvidia-tls.so.331.20...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/nvidia-331/tls/libnvidia-tls.so.331.20
Reading symbols from /usr/lib/nvidia-331/libnvidia-glcore.so.331.20...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/nvidia-331/libnvidia-glcore.so.331.20
Reading symbols from /lib/i386-linux-gnu/libdl.so.2...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/libdl-2.15.so...done.
done.
Loaded symbols for /lib/i386-linux-gnu/libdl.so.2
Reading symbols from /usr/lib/libImath.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libImath.so.6
Reading symbols from /usr/lib/libIex.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libIex.so.6
Reading symbols from /usr/lib/libIlmThread.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libIlmThread.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libxml2.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libxml2.so.2
Reading symbols from /usr/lib/i386-linux-gnu/libffi.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libffi.so.6
Reading symbols from /lib/i386-linux-gnu/libpcre.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libpcre.so.3
Reading symbols from /usr/lib/i386-linux-gnu/libgstbase-0.10.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libgstbase-0.10.so.0
Reading symbols from /usr/lib/i386-linux-gnu/liborc-0.4.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/liborc-0.4.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libraw1394.so.11...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libraw1394.so.11
Reading symbols from /lib/i386-linux-gnu/libusb-1.0.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libusb-1.0.so.0
Reading symbols from /usr/local/lib/libv4l2.so.0...done.
Loaded symbols for /usr/local/lib/libv4l2.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libogg.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libogg.so.0
Reading symbols from /lib/i386-linux-gnu/libexpat.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libexpat.so.1
Reading symbols from /usr/lib/i386-linux-gnu/libXt.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libXt.so.6
Reading symbols from /usr/lib/i386-linux-gnu/libXau.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libXau.so.6
Reading symbols from /lib/i386-linux-gnu/libuuid.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/i386-linux-gnu/libuuid.so.1
Reading symbols from /usr/lib/i386-linux-gnu/libxcb.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libxcb.so.1
Reading symbols from /usr/local/lib/libv4lconvert.so.0...done.
Loaded symbols for /usr/local/lib/libv4lconvert.so.0
Reading symbols from /usr/lib/i386-linux-gnu/libXdmcp.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/i386-linux-gnu/libXdmcp.so.6
Reading symbols from /usr/lib/i386-linux-gnu/gconv/UTF-16.so...Reading symbols from /usr/lib/debug/usr/lib/i386-linux-gnu/gconv/UTF-16.so...done.
done.
Loaded symbols for /usr/lib/i386-linux-gnu/gconv/UTF-16.so
Reading symbols from /usr/lib/libicui18n.so.48...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libicui18n.so.48
Reading symbols from /usr/lib/libicuuc.so.48...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libicuuc.so.48
Reading symbols from /usr/lib/libicudata.so.48...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libicudata.so.48
Failed to read a valid object file image from memory.
0x074444a2 in ?? () from /usr/lib/i386-linux-gnu/libfontconfig.so.1
(gdb) 
enzom83
  • 8,080
  • 10
  • 68
  • 114

5 Answers5

4

A segmentation fault occurs when the function cvCreateFileCapture is sometimes invoked using a network URL as argument, No error occur if the argument is a file on disk.

By symptom of the problem, your program experiencing some sort of memory corruption. In all probability the network URL flow execution is doing something(overflow/overwriting of memory) and it looks like you are able to reproduce this problem if you user network URL. However please don’t assume that if URL is a file on disk(locally), it does not have any problem. There could be possibility that corruption is happening in this way as well, it just that effect is getting delayed. Memory corruption problems are so hard to debug and there is no easy steps to identify them without performing extensive analysis of our program.

Looking at the stack trace, it would be almost impossible to find out the what could be the root cause of this as these segmentation fault would be after effect of something real bad done by program in early execution.

The best way to identify these memory corruption is to use some dynamic tools along with debugger(WinDBG/PageHeap on Windows). From your question(segmentation fault), it look like you might be running on Linux platform. So You may want to attach your program(a.out) in Valgrind/GDB.

$ valgrind --tool=memcheck --db-attach=yes ./a.out

This way Valgrind would attach your program in the debugger when your first memory error is detected so that you can do live debugging(GDB). This should be the best possible way to understand and resolve your problem. Once you are able to figure it out your first error, fix it and rerun it and see what are other errors you are getting.This steps should be done till no error is getting reported by Valgrind.

Mantosh Kumar
  • 5,659
  • 3
  • 24
  • 48
  • I will try to run the executable through valgrind and then post the output of valgrind. – enzom83 Apr 14 '14 at 20:26
  • Could the error be caused by the library _gstreamer_ (see the above stack trace)? – enzom83 Apr 14 '14 at 20:51
  • @enzom83:Yes, Valgrind would be really really useful to understand it. However from above steps(mentioned in my post), you would be able to do live debugging in gdb at closest possible place to actual corruption. I would suggest you to follow this approach as looking out the various arguments/memory information, we can get better information. However If you still facing difficulty you may post it in your question so that we could be able to provide you input on that. – Mantosh Kumar Apr 15 '14 at 00:49
  • @enzom83: Yes,it could be caused by gstreamer. But I believe gstreamer would be gets called even in the cases when you are passing local directory information.Try to understand from the perspective of who is the owner of that particular memory not the one who is using that(gstreamer).So we should always suspects our code first instead of library. Often our code would be wrong and the effect would be seen in library...... – Mantosh Kumar Apr 15 '14 at 00:55
  • Well, I run my program using valgrind and I got the above output. – enzom83 Apr 15 '14 at 07:16
  • @enzom83: Well it is difficult to identify the root of this problem without having the complete source code.I am able to see invalid read which typically indicates that your program is trying to read free memory(dangling)/invalid pointer. This could lead to segmentation fault. But to understand it, you would have to debug it by yourself(Valgrind/GDB).I have nothing to add in my post. – Mantosh Kumar Apr 17 '14 at 03:00
0

add cvWaitKey(100); before the cvQueryFrame(); function.

Surinder ツ
  • 1,778
  • 3
  • 16
  • 27
  • The function `cvQueryFrame` is invoked after the function `cvCreateFileCapture` is completed, so why should function `cvQueryFrame` be responsible for an error that occurs within the function `cvCreateFileCapture`? – enzom83 Apr 12 '14 at 10:01
0

If you are in a Linux environment, you can use valgrind to find out exactly where the segmentation fault is happening. Just type valgrind before the name of the program, or the way you execute your program. For example, if you execute your program with the following command:

hello -print

issue the following command instead:

valgrind hello -print

You can also "pepper" your code with different cout or printf statements and observe the last output before the segmentation fault. If the program is large, this method could be more cumbersome / less useful. You may be able to do it right before and right after every place cvCreateFileCapture appears in your main function to find out where it is occurring. If cvCreateFileCapture is part of opencv, it would appear to be a bug in opencv!

Jonathan
  • 1,050
  • 1
  • 12
  • 36
0

Check out this C++ code,

VideoCapture vcap;
Mat image;
const string videoStreamAddress = "rtsp://IPaddress:Port/Path?dummy=param.mjpg";// 

//open the video stream and make sure it's opened
if(!vcap.open(videoStreamAddress)) {
    cout << "Error opening video stream or file" << std::endl;
    return -1;
}

for(;;) {
    if(!vcap.read(image)) {
        cout << "No frame" << std::endl;
        waitKey();
    }
    imshow("Output Window", image);
    if(waitKey(1) >= 0) break;
}

And make sure that your stream is not password protected.

Haris
  • 13,645
  • 12
  • 90
  • 121
0

gst_caps_unref <- AFAIK this function free's memory used by gst object. I would like you to run your application under valgrind, but with following command: valgrind --leak-check=full ./a.out. And attach its output instead of one you have currently (it will be more informative, I assure you). It is possible that your bug will not reproduce under Valgrind as it provides something like 'private memory' for a program. In this case I would recommend you to get cgdb (great interface for gdb) and debug your program under it (check for variable values, possible nullpointers, deletions itd.)

Łukasz Daniluk
  • 460
  • 3
  • 9