本文介绍了在Xcode中找不到opencv2 / opencv.hpp文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了openCV来获取opencv2.framework。我通过构建阶段 - >链接二进制文件库将其添加到我的xcode iOS项目中,然后尝试在我的项目中包含opencv2 / opencv.hpp。
我收到错误opencv2 / opencv.hpp未找到。但该文件存在于框架中。我试图在网上找到一个解决方案,但没有任何对我有用。

I have built openCV to get opencv2.framework. I added this to my xcode iOS project by going to "build phases->Link Binary With Libraries", then tried to include "opencv2/opencv.hpp" in my project.I get the error "opencv2/opencv.hpp" not found. But the file exists in the framework. I have tried to find a solution online but nothing has worked for me.

我试图将其包含在的文件是.mm文件。我把编译源代码作为objective-c ++。任何帮助都会很棒。

The file I'm trying to include it in is a .mm file. I have made "compile sources as" objective-c++. Any help would be great.

推荐答案

花了我4个小时来解决这个问题。这就是我如何使用它:
随着opencv框架在构建阶段添加以下框架:

Took me 4 hours to figure this out. This is how I got this to work :Along with the opencv framework add the following frameworks in the build phases:

Accelerate,AssetsLibrary,AVFoundation
,CoreGraphics
,CoreImage
,CoreMedia
,CoreVideo
,QuartzCore
,UIKit
,Foundation。

Accelerate, AssetsLibrary, AVFoundation, CoreGraphics, CoreImage, CoreMedia, CoreVideo, QuartzCore, UIKit, Foundation.

然后,在.pch文件中,在UIKit和Foundation导入之前添加这些行:

Then, in the .pch file add these lines before UIKit and Foundation imports :

#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif

这篇关于在Xcode中找不到opencv2 / opencv.hpp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 06:19