关于opencv:用自制软件和python3安装opencv3时出错

Error in installing opencv3 with homebrew and python3

我正在使用自制软件在 OSX(EI Captain)上安装 opencv3,

1
brew install opencv3 --with-contrib --with-python3 --HEAD

并且发生错误:

1
2
3
4
5
6
7
8
9
Updating Homebrew...
==> Installing opencv3 from homebrew/science
==> Cloning https://github.com/opencv/opencv.git
Updating /Users/ksun/Library/Caches/Homebrew/opencv3--git
==> Checking out branch master
==> Cloning https://github.com/opencv/opencv_contrib.git
Updating /Users/ksun/Library/Caches/Homebrew/opencv3--contrib--git
> ==> Checking out branch master
Error: No such file or directory - /private/tmp/opencv3-20170330-14255-bxsn05/3rdparty/ippicv/downloader.cmake

你们能帮我找出解决方法吗?


我做brew edit opencv3,然后注释下面一行

1
2
3
inreplace buildpath/"3rdparty/ippicv/downloader.cmake",
 "${OPENCV_ICV_PLATFORM}-${OPENCV_ICV_PACKAGE_HASH}",
 "${OPENCV_ICV_PLATFORM}"

然后您可以使用 --HEAD

重新安装

opencv 存储库修复了一些问题,还删除了文件 3rdparty/ippicv/downloader.cmake,因此无需再对其进行修补。但是他们没有发布新版本,所以要安装 --with-contrib,你必须使用 --HEAD 安装,但禁用文件 3rdparty/ippicv/downloader.cmake

的补丁


我遇到了同样的问题。我通过运行 brew install opencv3 --with-contrib --with-python3

解决了它

我认为发生的事情是人们更新了 repo 中的 ../3rdparty/ippicv 文件夹,使得 downloader.cmake 文件不再存在,但他们尚未更新 brew 公式。

brew install without --HEAD 将构建 opencv3.2.0,这对我来说已经足够了。


当我搜索 OpenCV Java 问题时,这是第一个结果。我正在为使用 OpenCV Java 的任何人发布我的答案,以发现它也很有用。

我正在关注这篇文章:https://opencv-java-tutorials.readthedocs.io/en/latest/01-installing-opencv-for-java.html

1
2
brew tap homebrew/science
brew install opencv3 --HEAD --with-contrib --with-java

我尝试从上述命令中删除 --HEAD 并且能够成功安装它。

1
brew install opencv3 --with-contrib --with-java

根据这篇文章:https://github.com/Homebrew/homebrew-science/issues/5498


我已经通过以下方式解决了这个问题:

1
$ brew edit opencv3

找到以下代码块并注释所有 4 行:

1
2
3
4
if build.with?("python3") && build.with?("python")
  # Opencv3 Does not support building both Python 2 and 3 versions
  odie"opencv3: Does not support building both Python 2 and 3 wrappers"
end

最后使用 brew install 命令安装:

1
$ brew install opencv3 --with-contrib --with-python3

参考:http://www.pyimagesearch.com/2017/05/15/resolving-macos-opencv-homebrew-install-errors/