Simple application to install OpenCV.
This assumes that the OpenCV artifacts are located in the FRC maven repository at https://first.wpi.edu/FRC/roborio/maven/development
or in the local maven repository.
(Artifacts for this project are also available in the above repository)
For now, this is just a CLI app with no GUI.
This currently supports
- Windows (32- and 64-bit x86)
- Mac OS X 10.4 or higher
- Linux (32- and 64-bit x86, and ARM soft- and hard-float)
Artifacts are installed by default in C:\Users\<user>\OpenCV\
. You will need to add the install locations to the PATH
environment variable.
JNI and native bindings will be installed in /usr/local/lib
and the headers will be installed in /usr/local/include
. If you don't have write access to these folders, you can run the installer with
sudo java -Duser.home=$HOME -jar ...
Make sure that /usr/local/lib
is on LD_LIBRARY_PATH
or the JNI bindings won't be loaded by the JVM.
Similar to Linux, but you probably won't need to use sudo
.
Short name | Long name | Description | Argument |
---|---|---|---|
h |
help |
Prints the help text | |
v |
version |
Sets the OpenCV version | The version in the format x.x.x e.g. 3.1.0 |
j |
java |
Flags the Java API for install. This does not install JNI bindings | Install location (optional) |
i |
jni |
Flags the JNI bindings for install | Install location (optional) |
s |
headers |
Flags the C++ headers for install | Install location (optional) |
n |
natives |
Flags the C++ native libraries for install | Install location (optional) |
a |
all |
Installs all OpenCV artifacts | |
o |
overwrite |
Overwrite already installed files | |
p |
platform |
Download artifacts for a specific platform. They will be located in ./install |
The platform to download artifacts for |
windows-x86
windows-x86_64
osx-x86_64
linux-x86
linux-x86_64
linux-arm
linux-armhf
java -jar opencv-installer --version <version> --platform <platform> --java <location> --jni <location> --headers <location> --natives <location> --overwrite
buildscript {
repositories {
maven {
url 'https://github.com/WPIRoboticsProjects/opencv-maven/raw/mvn-repo'
}
}
dependencies {
classpath group: 'edu.wpi.first.wpilib.opencv', name: 'opencv-installer', version: '+'
}
}
import edu.wpi.first.wpilib.opencv.installer.Installer
import edu.wpi.first.wpilib.opencv.installer.PlatformDetector
def openCvPlatform = PlatformDetector.getPlatform()
def openCvVersion = '3.1.0'
dependencies {
compile group: 'org.opencv', name: 'opencv-java', version: openCvVersion
...
}
task installOpenCvJni(type: Copy) {
Installer.setVersion(openCvVersion)
Installer.installJni(openCvPlatform.defaultJniLocation())
// Or manually set the install location
Installer.installJni('/usr/local/lib')
}
First, add
repositories {
maven {
url 'https://github.com/WPIRoboticsProjects/opencv-maven/raw/mvn-repo'
}
}
dependencies {
compile group: 'edu.wpi.first.wpilib.opencv', name: 'opencv-installer', version: '+'
}
to your build.gradle
file.
Then to make sure that OpenCV is installed prior to using any OpenCV code:
import edu.wpi.first.wpilib.opencv.installer.Installer;
import edu.wpi.first.wpilib.opencv.installer.PlatformDetector;
import org.opencv.core.Core;
class Main {
static {
Installer.setOpenCvVersion(Core.VERSION);
Installer.installJni(PlatformDetector.getPlatform().defaultJniLocation());
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
}
This will install OpenCV on the current system if the JNI bindings are available for it. If there aren't any JNI bindings, an IOException
will be thrown by the call to Installer.installJni()