问题描述
我正在编写一个iPhone应用程序,我正在使用OpenCV进行一些图像处理。到目前为止我只在普通的C中使用它,但现在我需要使用C ++来创建一些基本的OCR。
I'm coding an iPhone app and I'm using OpenCV for some image processing. I have only used it in plain C so far but now I need to use C++ to create some basic OCR.
我首先创建了一个.h / .cpp文件,它似乎编译得很好。但我需要将它与一些Objective-C混合打开图像等等。然后我将文件重命名为.mm而不是.cpp,但它不会编译!
I first created a .h/.cpp file and it seems to compile fine. But I need to mix this with some Objective-C to open images and so on. I then renamed the file to .mm instead for .cpp but it won't compile!
我收到此错误:
仅允许语句表达式内部函数在OpenCV core.hpp第432行
I get this error:"Statement-expressions are allowed only inside functions" in OpenCV core.hpp line 432
第432行是这一行:
typedef Matx<_Tp, MIN(m, n), 1> diag_type;
为什么会出现这种情况的任何想法?
Any ideas why this might happen?
推荐答案
我遇到了同样的问题。我在UIKit标头之前导入了Open-CV标头。确保在pch文件中执行此操作。问题在于UIKit和OpenCV中都定义了一些宏。
I had the same issue. I imported the Open-CV header before the UIKit headers. Make sure you do this in the pch file. The issue is with some macro defined in both UIKit and OpenCV.
来源:
Maunil
这篇关于混合Objective-C和C ++以及OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!