Ask Your Question
0

Problem opening then displaying AVI file

asked 2013-08-15 16:42:13 -0600

khansen gravatar image

updated 2013-08-15 17:17:09 -0600

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! 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 ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2013-08-16 01:45:56 -0600

According to this topic http://social.msdn.microsoft.com/Forums/vstudio/en-US/4b8ba632-e0aa-41f7-a651-b333aa7406c6/firstchance-exception-at-0x7c9194fe-ntdlldll-in-my-application-why it comes to мixing both the retail version of msvcr80.dll and the debug version msvcr80d.dll. Try to change from debug to release or vice-versa ;)

edit flag offensive delete link more

Comments

I looked into that. Unfortunately, that's not my problem. OpenCV is hyper-specific about what AVI formats it supports. My uncompressed 24 bit RGB (RV24) coming out of iSpy didn't meet those specs.

http://opencv.willowgarage.com/wiki/VideoCodecs

khansen gravatar imagekhansen ( 2013-08-16 11:55:03 -0600 )edit

Question Tools

Stats

Asked: 2013-08-15 16:42:13 -0600

Seen: 1,943 times

Last updated: Aug 16 '13