混合Objective-C和C ++以及OpenCV [英] Mix Objective-C and C++ and OpenCV

查看:153
本文介绍了混合Objective-C和C ++以及OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个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.

来源: http://computer-vision-talks.com/2011/01/using-opencv-in-objective-c-code/

Maunil

这篇关于混合Objective-C和C ++以及OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆