java 如何在 Arch Linux 上安装 OpenCV
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45175295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install OpenCV on arch linux
提问by Reuben_v1
I have tried installing opencv on arch using the aur package. It has successfully installed but when I try to import opencv2 in python, I get the following error
我尝试使用 aur 包在 arch 上安装 opencv。它已成功安装,但是当我尝试在 python 中导入 opencv2 时,出现以下错误
ImportError: libhdf5.so.100: cannot open shared object file: No such file or directory
Not just python , even when I tried running a c++ sample code using this, I got the same error. I have tried searching the net, found a few people who faced a similar issue but still I am unable to fix it.
不仅仅是 python ,即使我尝试使用它运行 c++ 示例代码,我也遇到了同样的错误。我试过在网上搜索,发现一些人遇到了类似的问题,但我仍然无法解决它。
I have installed Open CV version 3.2
我已经安装了 Open CV 3.2 版
回答by Reuben_v1
I finally fixed this issue. It was a silly one but confusing at the same time because there are multiple packages with similar names but only one works. Moreover, not many have posted about this issue online and hence I am posting my solution with the hope that it might help save someone else's time.
我终于解决了这个问题。这是一个愚蠢但同时令人困惑的方法,因为有多个名称相似的包,但只有一个有效。此外,没有多少人在网上发布了有关此问题的信息,因此我发布了我的解决方案,希望它可以帮助节省其他人的时间。
Step 1 : Run this command(Optional if you have already installed OpenCV)
第 1 步:运行此命令(如果您已经安装了 OpenCV,则可选)
pacman -Syu base-devel opencv opencv-samples
Step 2 : Just install this package
第 2 步:只需安装此软件包
https://www.archlinux.org/packages/community/x86_64/hdf5/
https://www.archlinux.org/packages/community/x86_64/hdf5/
Done!
完毕!
回答by user202729
In version 4, in the default configuration, compiling opencv
requires hdf5
and vtk
, however it's not listed as a dependency
of opencv
.
在版本 4 中,在默认配置中,编译opencv
需要hdf5
和vtk
,但是它没有被列为 的依赖项opencv
。
That is mentioned in the two bugs on archlinux page: 1, 2.
这在 archlinux 页面上的两个错误中提到:1, 2。
There are 2 possible workarounds:
有两种可能的解决方法:
sudo pacman -S hdf5 vtk
(takes about231.24 MiB
of memory)- If your program don't require
hdf5
andvtk
, remove-lopencv_hdf
and-lopencv_viz
from/usr/lib/pkgconfig/opencv4.pc
(in case the program usepkg-config
), or remove the 2 flags while compiling.
sudo pacman -S hdf5 vtk
(占用大约231.24 MiB
内存)- 如果您的程序不需要
hdf5
andvtk
,请删除-lopencv_hdf
and-lopencv_viz
from/usr/lib/pkgconfig/opencv4.pc
(以防程序使用pkg-config
),或在编译时删除 2 个标志。
Warning: If you use workaround 2, update of opencv
package will revert those changes. You may want to add them as a NoUpgrade
entry in pacman.conf
(read man page for details), but the file will no longer be updated and something else may break.
警告:如果您使用变通方法 2,opencv
包的更新将恢复这些更改。您可能希望将它们添加为NoUpgrade
条目pacman.conf
(阅读手册页了解详细信息),但文件将不再更新并且其他内容可能会中断。