ofxOpenCv - Unable to use VideoCapture class?

Hello,

I am attempting to get the VideoCapture class provided by OpenCV working in OF, though I am having no luck. I have included the appropriate header files and am creating the object like so:

#pragma once

#include "ofMain.h"
#include "opencv2/core.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"


class ofApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();
    
    cv::VideoCapture capture;
   	
};

Xcode keeps returning the error “No type named ‘VideoCapture’ in namespace ‘cv’”. I seem to be able to access everything else within the cv namespace, so unsure why this is happening.

Any help is much appreciated!

Hello,
I don’t think that the VideoCapture classes are included in OF.
You could try using an ofVideoGrabber and set an ofxCvImage from the pixels.
Then you could grab the IplImage* using getCvImage or using a new method only in the nightlies to get the cv::Mat

Then perform cv operations on those.

2 Likes

Thanks so much! I was able to work around my problem using the getCvMat() method.