【发布时间】:2012-07-28 21:20:02
【问题描述】:
有一篇文章描述了如何做到这一点here,这似乎对其他人有用,但它不适合我。
这是使用的 .h 文件的副本:
//
// NSImage+OpenCV.h
//
#import <AppKit/AppKit.h>
@interface NSImage (NSImage_OpenCV) {
}
+(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat;
-(id)initWithCVMat:(const cv::Mat&)cvMat;
@property(nonatomic, readonly) cv::Mat CVMat;
@property(nonatomic, readonly) cv::Mat CVGrayscaleMat;
@end
我在 Xcode 4.4 上,使用 openCV 2.4.2。我为头文件得到的编译器错误是以下的 4 倍:
Semantic issue: Use of undeclared identifier 'cv'
这个错误似乎很明显......头文件没有定义 cv::Mat 是什么。 所以我通过查看 OpenCV 2.4 教程进行了猜测,我需要添加
#include <opencv2/core/core.hpp>
这产生了 20 个其他错误,编译器抱怨 core.hpp 文件。 其中第一个说:
Semantic issue: Non-const static data member must be initialized out of line
所以我的问题是我做错了什么?如何让这段代码工作?
【问题讨论】: