OpenCV 4 IOS

来源:互联网 发布:iphone拍视频软件 编辑:程序博客网 时间:2024/05/28 05:16

最近有机会接触到Opencv,菜鸟一个,将这开源库使用在iOS上碰到了不少问题,也找到了一些资料,

所以向再这边做下总结,好让自己以后碰到的时候可以快速解决。

要将Opencv使用在iOS上需要到http://opencv.org网站(网站右边有个Opencv For iOS ,点击既可下载)上下载opencv2.framework。其实有了这库的我页不知道怎么用的。所以google了下有没有这方面的Demo的。一下是我找到的它官网发布的iOS的Demo。

Demo:http://code.opencv.org/projects/gsoc2012/repository/entry/ios/trunk
CVPR2012演讲稿:http://code.opencv.org/projects/gsoc2012/repository/entry/ios/trunk/doc/CVPR2012_OpenCV4IOS_Tutorial.pdf

开始点Demo想下载的当不知道怎么下载。后来看到一个帖子http://blog.csdn.net/harveofhust/article/details/6099295

我也就用终端试了下。

在终端中执行

svn co http://code.opencv.org/svn/gsoc2012/ios/trunk/

没想居然把这东西给down下来了。这部分的我也还不是很清楚,就知道这样成了。有知道的大牛可以讲解下的。

down下的源码的我用xcode打开的发现opencv2.framework的都是红色,反正我也下载了就把原先的删除了加了我下的。

其中一个打开运行的成功了。我还以为成了。后来打开几个的做了相同的修改的,但是却是出现了报错。

Undefined symbols for architecture i386: "cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)", referenced from: MatToUIImage(cv::Mat const&) in ViewController.o "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from: std::__1::enable_if<__is_forward_iterator<unsigned long*>::value, void>::type std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >::assign<unsigned long*>(unsigned long*, unsigned long*) in opencv2(matrix.o) std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >::vector(unsigned long) in opencv2(matrix.o) std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >::__append(unsigned long) in opencv2(matrix.o) std::__1::vector<cv::Vec<float, 2>, std::__1::allocator<cv::Vec<float, 2> > >::vector(unsigned long) in opencv2(matrix.o) std::__1::vector<int, std::__1::allocator<int> >::vector(unsigned long) in opencv2(matrix.o) std::__1::vector<cv::Vec<int, 128>, std::__1::allocator<cv::Vec<int, 128> > >::__append(unsigned long) in opencv2(matrix.o) std::__1::vector<cv::Vec<int, 64>, std::__1::allocator<cv::Vec<int, 64> > >::__append(unsigned long) in opencv2(matrix.o) ...

google了错误居然没几条结果,找了都没合适的。在其中文论坛也找了下。也没找到。

在这分享下它的中文网站:http://www.opencv.org.cn/index.php/Template:Doc

后来在官网上盲目的找了下。试了几个的居然可以。

http://answers.opencv.org/question/4655/link-error-for-only-cascadeclassifier-under-243/

It turns out that even though I switched from libstdc++ to libc++, I was still compiling against libstdc++, so this lead to some of the method signatures not matching at link time. To fix this:

  • In the Build Settings tab for your project, scroll down to "Apple LLVM Compiler 4.1 - Language"
  • Set the setting "C++ Language Dialect" to "C++11 [-std=c++11]"
  • Set the setting "C++ Standard Library" to "libc++ (LLVM standard C++ library with C++11 support)"

(You'll also need to switch the C++ runtime library from libstdc++ to libc++ in the "Link Binary With Libraries" section of the "Build Phases" tab.)

其中主要的就是可能库中是有用c++来编写的,所以需要将bulid settings中的几项需要设置下。

到此忙了半天终于能把其Demo正常运行起来。明天开始研究Demo。搞起。




原创粉丝点击