Unknown type 'CvVideoCamera'

asked 2017-02-19 13:23:10 -0600

mddrill gravatar image

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

edit retag flag offensive close merge delete

Comments

You got your import for it?

#import "cap_ios.h"
Tetragramm gravatar imageTetragramm ( 2017-02-19 15:50:54 -0600 )edit

@Tetragramm I think that's been replaced by #include <opencv2/imgcodecs/ios.h>, it says "cap_ios.h" not found

mddrill gravatar imagemddrill ( 2017-02-19 17:56:58 -0600 )edit

Mm, no. I definitely see a cap_ios.h in my directory. In the videoio module. You may need to go opencv2/videoio/cap_ios.h

Tetragramm gravatar imageTetragramm ( 2017-02-19 20:01:58 -0600 )edit