我正试图在我的Mac上安装OpenCV,使用本教程:https://medium.com/macoclock/setting-up-mac-for-opencv-java-development-with-intellij-idea-fd2153eb634f
当我这么做时:
brew安装opencv
我收到:
==> Searching for similarly named formulae...
These similarly named formulae were found:
opencv opencv@2 opencv@3
To install one of them, run (for example):
brew install opencv
Error: No available formula or cask with the name "opencv".
==> Searching taps on GitHub...
Error: No formulae found in taps.它显示"opencv“公式,那么它为什么不安装它呢?怎么修?
我还做了以下工作:
> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates和
> brew install ant
Warning: ant 1.10.9 is already installed and up-to-date
To reinstall 1.10.9, run `brew reinstall ant`当尝试
brew安装-从源代码构建opencv
然后接收相同的错误。
也曾尝试过:
> brew uninstall opencv
Error: No available formula or cask with the name "opencv".发布于 2021-01-18 20:17:29
显然,通过自制的方式安装OpenCV比通过brew install opencv安装更多。
您需要确保安装了XCode命令行工具以及ANT。那你就得跑
brew install --build-from-source opencv
有关细节和细节,请查看文档。
这也可能是一个自制的问题-所以更新brew并运行医生。
发布于 2021-01-19 01:32:51
我找到了让OpenCV通过Maven的更简单的方法。
添加到pom.xml中:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.openpnp/opencv -->
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>4.3.0-3</version>
</dependency>
</dependencies>添加依赖项后,需要加载库以供使用。通常,您会使用以下一行:
System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 但是,它将不能使用此方法。您需要将其更改为以下一行之一:
nu.pattern.OpenCV.loadShared();
nu.pattern.OpenCV.loadLocally(); // Use in case loadShared() doesn't work因此,最终的测试结果是:
import org.opencv.core.Core;
public class HelloCV {
static {
nu.pattern.OpenCV.loadShared();
// nu.pattern.OpenCV.loadLocally(); // Use in case loadShared() doesn't work
}
public static void main(String[] args) {
System.out.println(Core.VERSION);
System.out.println(Core.VERSION_MAJOR);
System.out.println(Core.VERSION_MINOR);
System.out.println(Core.VERSION_REVISION);
System.out.println(Core.NATIVE_LIBRARY_NAME);
System.out.println(Core.getBuildInformation());
}
}https://stackoverflow.com/questions/65781395
复制相似问题