Reputation: 6036
I am trying to install OpenCV on my Mac using this tutorial: https://medium.com/macoclock/setting-up-mac-for-opencv-java-development-with-intellij-idea-fd2153eb634f
When I do:
brew install opencv
I receive:
==> 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.
It displays "opencv" formula, so why it does not install it? How to fix?
Also I have done:
> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
and
> brew install ant
Warning: ant 1.10.9 is already installed and up-to-date
To reinstall 1.10.9, run `brew reinstall ant`
when try
brew install --build-from-source opencv
then receive the same error.
Also tried:
> brew uninstall opencv
Error: No available formula or cask with the name "opencv".
Upvotes: 0
Views: 1991
Reputation: 6036
I found easier way to get OpenCV through Maven.
Add to 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>
After adding the dependency, you need to load the library for use. Normally, you would use the line:
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
however it will not work with this method. You need to change it to one of these lines:
nu.pattern.OpenCV.loadShared();
nu.pattern.OpenCV.loadLocally(); // Use in case loadShared() doesn't work
So the final result for test is:
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());
}
}
Upvotes: 2
Reputation: 10696
Apparently, there's more to do with installing OpenCV via homebrew than brew install opencv
.
You need to make sure you have XCode Command Line Tools installed, as well as ANT. Then you need to run
brew install --build-from-source opencv
Take a look at the documentation for details and specifics.
Also it might be a homebrew issue - so update brew and run doctor.
Upvotes: 2