OpenCV2.2 with Visual Studio 2008

asked 2017-05-18 02:02:43 -0600

Ajai gravatar image

updated 2017-05-18 02:24:51 -0600

berak gravatar image

I am very new to OpenCV. I downloaded and installed Open CV according to the instructions in the link https://rangadabarera.wordpress.com/o... . My requirement is to create a video library that can be used to replace the existing video library that uses Video For Windows(VFW). I am trying to write a sample code to open and read an avi file. I added the following libraries "opencv_core220.lib opencv_highgui220.lib opencv_video220.lib opencv_ffmpeg220.lib". The code i have written looks like as follows

#include <iostream>

#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
using namespace cv;
int main()
{
    string filename ("C:\\ADAS_AHBC_201046_002.avi") ; 

    VideoCapture input;
    bool status = input.open( filename );
    if (!input.isOpened()) return 0;
    int frameCount = input.get(CV_CAP_PROP_FRAME_COUNT);
}

But while running the code, i am getting an exception with the following text Unhandled exception at 0x00905a4d in aviread.exe: 0xC0000005: Access violation. The value of the obj and referance count fields within the VideoCapture object seems to be 0

I tried another version like as follows and the output is the same

int main()
{
    string filename ("C:\\ADAS_AHBC_201046_002.avi") ; 

    VideoCapture input = VideoCapture( filename );
    //bool status = input.open( filename );
    if (!input.isOpened()) return 0;
    int frameCount = input.get(CV_CAP_PROP_FRAME_COUNT);
}

But when i tried to to read from a camera, it seems like not throwing any error. The code is as follows int main() { string filename ("C:\ADAS_AHBC_201046_002.avi") ;

    VideoCapture input = VideoCapture( 0 );
    //bool status = input.open( filename );
    if (!input.isOpened()) return 0;
    int frameCount = input.get(CV_CAP_PROP_FRAME_COUNT);
}

While debugging this code, my lap's camera is getting invoked. Can you please help me understand as what is wrong with what i am doing.

Thanks AJAI

edit retag flag offensive close merge delete

Comments

  • VideoCapture( 0 ); will indeed open the webcam
  • the libs you mention at the beeginning of your post are RELEASE ones. are you running a DEBUG project ? (which is the default with VS.) then you 'd need opencv_core220d.lib, etc.
  • opencv2.2 is FAR TOO OLD, to be useful nowadays. try to update your compiler and use a more recent opencv codebase. also look for more recent tutorials / blogs.
berak gravatar imageberak ( 2017-05-18 02:27:55 -0600 )edit

Hi, I am working with release. In debug when i tried to run the application it wasnt showing any exception but the value of the obj and refcount are 0s. I tried to create the debug information in Release. When i removed the debug information, its not giving any exception. But the values is same in the Debug.

Thanks AJAI

Ajai gravatar imageAjai ( 2017-05-18 04:51:19 -0600 )edit

please strictly use release libs with release build, and debug libs with debug build.

then, trying to debug a release build won't give you any valid information (the values are all bogus)

again, any chance, you can update your whole environment ? noone can reproduce your problems any more, it's all far too long ago. (and no more relevant to the devs/community)

berak gravatar imageberak ( 2017-05-18 04:57:10 -0600 )edit

Hi, Now i realized the issue with the file opening is not related to the version of OpenCV. The file that i was trying to open was created with a Custom Codec known as DJIP. I tried with a downloaded avi file and that was working. Now i need to know how can i open or add support to a custom codec generated video file. I read somewhere that the Videos are open using ffmpeg.

Thanks AJAI

Ajai gravatar imageAjai ( 2017-07-08 09:36:20 -0600 )edit