Ask Your Question

Revision history [back]

OpenCV VideoCapture does not work as pointer or member variable

I have a very strange hevaviour with opencv3.0.0 c++ in visual studio 2010 on windows7.

I simply want to open a video file to grab/extract frames from it. When i create a local variable in my cpp, everything works fine:

VideoCapture inputVideo;  
bool loadOk = inputVideo.open(filename);  //loadOk is true

When i do a pointer in my cpp, the open process does not work.

VideoCapture * inputVideo = new VideoCapture();
bool loadOk = inputVideo->open(filename);  //loadOk is false

When i create a member variable in my header file, it is also not working

Header:
    VideoCapture m_inputVideo;
CPP:
    bool loadOk = m_inputVideo.open(filename); //loadOk is false


Header:
    VideoCapture * m_inputVideo;
CPP:
    m_inputVideo = new VideoCapture();
    bool loadOk = m_inputVideo->open(filename);  //loadOk is false

Can you help me get rid of this problem? I really need to declare the videocapture as member variable so i can acess it throughout my whole program. greetings, Julian