Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unknown type 'CvVideoCamera'

I am trying to use OpenCV to process video feed in an Swift iOS app.

I read that the best way to do this is with the CvVideoCamera class in an objective-c wrapper.

When I try to declare a CvVideoCamera object or pointer I get the error Unkown type 'CvVideoCamera'

Here is my code

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController{
    CvVideoCamera videoCamera;
    cv::Mat src;
}
@end

Here is my prefix header

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#include <opencv2/imgcodecs/ios.h>
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

#endif /* PrefixHeader_pch */

I know that opencv is being included in the project because when I remove the line where I declare a CvVideoCamera The code builds with no errors, even though I declare a Mat object.

I tried using the cv scope in front of CvVideoCamera, When I do that I get and error No type named CvVideoCapture in namespace cv

I have also tried putting the CvVideoCamera declaration in the implementation instead or the interface, changing the .m files to .mm, and declaring a pointer instead of an object;I still get the same errors.

When I look in the 0pencv2/imgcodecs/ios.h file, this is what I find

#import <UIKit/UIKit.h>
#import <Accelerate/Accelerate.h>
#import <AVFoundation/AVFoundation.h>
#import <ImageIO/ImageIO.h>
#include "opencv2/core/core.hpp"

//! @addtogroup imgcodecs_ios
//! @{

UIImage* MatToUIImage(const cv::Mat& image);
void UIImageToMat(const UIImage* image,
                         cv::Mat& m, bool alphaExist = false);

//! @}

There is nothing in there about CvVideoCamera, which leads me to believe I may be using the wrong include file, but everything I look up says that that is the right one to include

Any help would be appreciated, Thank You