Mac OS X 上的 OpenCV 安装 [英] OpenCV installation on Mac OS X

查看:40
本文介绍了Mac OS X 上的 OpenCV 安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在我的 Mac 上安装愚蠢的 OpenCV,我浏览了所有 Google 和 Stack Overflow 的搜索结果,但所有方法都完全没有用.

I have trawled through all of Google's and Stack Overflow's search results in order to install stupid OpenCV on my Mac and all the methods have been completely useless.

我开始尝试使用 OS X 10.8 及其 XCode 版本执行此操作,但没有成功.现在我使用 10.9 和 XCode 5.0.1.

I started trying to do this with OS X 10.8 and its XCode version and it didn't work. Now I'm on 10.9 and XCode 5.0.1.

我主要尝试了两种方法:1) 从 OCV 网站下载 .dmg 文件并执行 CMAKE 例程.当我到达 make -j8 步骤时,在大约 36% 时它会给我错误,例如:

I have tried mainly 2 methods: 1) Downloading the .dmg file from OCV website and doing the CMAKE routine. When I get to the make -j8 step, at around 36% it gives me errors such as:

-make[1]: * [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/all] 错误 2

-make[1]: * [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/all] Error 2

-Documents/Libraries/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12:注意:从宏CV_PERF_TEST_MAIN_INTERNALS"扩展而来while (++argc >= (--argc,-1)) {VA_ARGS;break;}/这个丑陋的缺点......^ ~~产生了 1 个错误.make[2]: ** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/perf_main.cpp.o] 错误 1

-Documents/Libraries/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note: expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS' while (++argc >= (--argc,-1)) {VA_ARGS; break;} /this ugly cons... ^ ~~ 1 error generated. make[2]: ** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/perf_main.cpp.o] Error 1

2) 最后使用 Homebrew,即使我添加了 python 路径,当我执行 'import cv' 时,它会给我一个没有名为 cv 的模块"错误

2) Using Homebrew at the end of which, even if I added the python path, when I do 'import cv' it gives me a "no module named cv" error

不久前我也尝试过 Macports,所以我不记得步骤了,但是没有用.

I tried Macports as well a while ago so I don't remember the steps, but it didn't work.

不用说,我已经尝试过不同版本的 OCV,但都在 make 步骤中给了我问题.

It goes without saying that I've tried different versions of OCV and all have given me issues at the make step.

还有其他解决方案吗?

推荐答案

有一个很棒的教程位于 这里.它突出显示您尝试使用的版本不兼容".我认为您应该尝试安装这些说明中所述的版本,然后看看效果如何.

There is a great tutorial located here. It highlights that the version you are trying to use "is not compatible". I am thinking that you should try installing the version stated in those instructions and see how you go.

以下说明直接取自该链接:

安装 CMAKE

  1. 首先你需要在这里下载CMake的Binary Distribution下的.dmg文件.在我安装它时,文件名为 cmake-2.8.11.2-Darwin64-universal.dmg.

  1. First you need to download the .dmg file under Binary Distribution of CMake here. At the time of I installed this, the file name is cmake-2.8.11.2-Darwin64-universal.dmg.

安装完成后会提示是否将CMake放入/usr/bin中,选择Yes完成安装

Upon completion of the installation you will be prompted whether to put CMake in /usr/bin, select Yes and finish installation

为确保 CMake 已成功安装,请在终端中输入 cmake -version

To ensure that CMake has been successfully installed, type cmake -version in Terminal

安装 OPENCV

  1. 首先,请在此处下载 OpenCV 2.4.3 稳定版的 tar 文件,请勿使用最新版本.我在安装过程中遇到了困难,因为我使用的是 OpenCV 2.4.6.1,但它尚不兼容.

  1. First, download the tar file of OpenCV 2.4.3 stable version here and DO NOT use the latest version. I struggled with the installation because I used OpenCV 2.4.6.1 and it's not yet compatible.

解压文件夹中的tar文件并通过终端进入该文件夹,例如cd 下载/OpenCV-2.4.3

Extract the tar file in a folder and go to that folder through the terminal, e.g. cd Downloads/OpenCV-2.4.3

现在,下面每一行都要在Terminal中执行,并且必须成功执行(没有错误)

Now, each of the following line is to be executed in Terminal and must be executed successfully (no error)

  1. mkdir 构建
  2. cd build
  3. cmake -G "Unix Makefiles" ..
  4. make -j8
  5. sudo make install

  • 您已准备好使用 OpenCV!

  • You are all set to use OpenCV!

    这篇关于Mac OS X 上的 OpenCV 安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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