OpenCV VideoCapture does not work as pointer or member variable

asked 2016-07-28 04:44:49 -0600

Julian gravatar image

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

edit retag flag offensive close merge delete

Comments

Bumping this. Same (or quite similar) issue (opencv 3.4.3, VS17)

SlaxX gravatar imageSlaxX ( 2018-09-22 06:56:58 -0600 )edit