Connor H
Connor H

Reputation: 346

Get mat from VideoCapture in OpenCV 3

I'm trying to capture video from a camera and I need to be able to pull frames as a Mat. I have done this before in OpenCV 2.4.9 in C++, but using the latest 3.0 build my program crashes.

Mat frame;
VideoCapture capture;
capture = VideoCapture(0);
if (!capture.isOpened())
{
    // Just a check. Program does not enter this
}

m_capture >> m_frame; // Program breaks here

The same code ran okay on 2.4.9, so I'm a little stumped here.

Upvotes: 2

Views: 2266

Answers (1)

Connor H
Connor H

Reputation: 346

I figured it out. Instead of doing capture = VideoCapture(0); I just needed to do m_capture.open(0);

Upvotes: 1

Related Questions