Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem opening then displaying AVI file

Hello,

The program below is supposed to open an AVI file that is stored in the app directory then display it, but it's crashing when I run it. I'm new to C++ and OpenCV, this issue has been driving me mad all day, and I've looked all over the internet for a solution. Please help!

This is the error I'm getting:

First-chance exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.
Unhandled exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.

The point at which the debugger places the break is at line 45 (bool bSuccess = cap.read(curVid);).

Code:

#define _CRT_SECURE_NO_DEPRECATE

#include <sstream>
#include <string>
#include <iostream>
#include <opencv\highgui.h>
#include <opencv\cv.h>
#include <vector>
#include <background_segm.hpp>
#include <opencv2/opencv.hpp>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>

using namespace cv;
using namespace std;

int nmixtures = 2;
int bShadowDetection = 1;
int history = 2;

Mat oriImg;     // original still image from IP Cam
Mat curVid;     // live feed from IP Cam
Mat difImg;     // resultant image from background subtraction 

int main(int argc, char *argv[])
{
    // get cam feed and show in new window
    VideoCapture cap("1_2013-08-15_10-38-25.avi");
     if (!cap.isOpened())  // if not success, exit program
    {
         cout << "Cannot open the video file" << endl;
         return -1;
    }
    double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
    double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
    cout << "Frame size : " << dWidth << " x " << dHeight << endl;
    namedWindow("Current Video", CV_WINDOW_AUTOSIZE);


    // show images in windows
    while(1)
    {
        // show camera feed
        bool bSuccess = cap.read(curVid); // read a new frame from video
        if (!bSuccess) //if not success, break loop
        {
            cout << "Cannot read a frame from video file" << endl;
            break;
        }
        imshow("Current Video", curVid);
        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
      {
            cout << "esc key is pressed by user" << endl;
            break; 
      }
    }

    return 0;
}

Here is the output and errors I get when debugging:

'iotaCam4.exe': Loaded 'C:\Users\khanse\Documents\Visual Studio 2010\Projects\iotaCam4\Debug\iotaCam4.exe', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\sysfer.dll', Cannot find or open the PDB file
'iotaCam4.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_core246d.dll', Cannot find or open the PDB file
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_highgui246d.dll', Cannot find or open the PDB file
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\comctl32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\avifil32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msacm32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvfw32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\avicap32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_ffmpeg246.dll', Binary was not built with debug information.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\wsock32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Symbols loaded (source information stripped).
First-chance exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.
Unhandled exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.

Problem opening then displaying AVI file

Hello,

The program below is supposed to open an AVI file that is stored in the app directory then display it, but it's crashing when I run it. I'm new to C++ and OpenCV, this issue has been driving me mad all day, and I've looked all over the internet for a solution. Please help!help! I'm using OpenCV 2.4.6 with VS 2010 on a x64 machine.

This is the error I'm getting:

First-chance exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.
Unhandled exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.

The point at which the debugger places the break is at line 45 (bool bSuccess = cap.read(curVid);).

Code:

#define _CRT_SECURE_NO_DEPRECATE

#include <sstream>
#include <string>
#include <iostream>
#include <opencv\highgui.h>
#include <opencv\cv.h>
#include <vector>
#include <background_segm.hpp>
#include <opencv2/opencv.hpp>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>

using namespace cv;
using namespace std;

int nmixtures = 2;
int bShadowDetection = 1;
int history = 2;

Mat oriImg;     // original still image from IP Cam
Mat curVid;     // live feed from IP Cam
Mat difImg;     // resultant image from background subtraction 

int main(int argc, char *argv[])
{
    // get cam feed and show in new window
    VideoCapture cap("1_2013-08-15_10-38-25.avi");
     if (!cap.isOpened())  // if not success, exit program
    {
         cout << "Cannot open the video file" << endl;
         return -1;
    }
    double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
    double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
    cout << "Frame size : " << dWidth << " x " << dHeight << endl;
    namedWindow("Current Video", CV_WINDOW_AUTOSIZE);


    // show images in windows
    while(1)
    {
        // show camera feed
        bool bSuccess = cap.read(curVid); // read a new frame from video
        if (!bSuccess) //if not success, break loop
        {
            cout << "Cannot read a frame from video file" << endl;
            break;
        }
        imshow("Current Video", curVid);
        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
      {
            cout << "esc key is pressed by user" << endl;
            break; 
      }
    }

    return 0;
}

Here is the output and errors I get when debugging:

'iotaCam4.exe': Loaded 'C:\Users\khanse\Documents\Visual Studio 2010\Projects\iotaCam4\Debug\iotaCam4.exe', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\sysfer.dll', Cannot find or open the PDB file
'iotaCam4.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_core246d.dll', Cannot find or open the PDB file
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_highgui246d.dll', Cannot find or open the PDB file
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Symbols loaded.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\comctl32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\avifil32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msacm32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msvfw32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\avicap32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_ffmpeg246.dll', Binary was not built with debug information.
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\wsock32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Symbols loaded (source information stripped).
'iotaCam4.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Symbols loaded (source information stripped).
First-chance exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.
Unhandled exception at 0x76daa048 (msvcrt.dll) in iotaCam4.exe: 0xC0000005: Access violation reading location 0x009907e0.