An open API service indexing awesome lists of open source software.

https://github.com/wpiroboticsprojects/opencv-installer

Simple application to install OpenCV
https://github.com/wpiroboticsprojects/opencv-installer

Last synced: about 1 year ago
JSON representation

Simple application to install OpenCV

Awesome Lists containing this project

README

          

# opencv-installer
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)

[Link to the maven repo](https://first.wpi.edu/FRC/roborio/maven/development)

For now, this is just a CLI app with no GUI.

## Supported platforms
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)

### Windows notes

Artifacts are installed by default in `C:\Users\\OpenCV\`. You will need to add the install locations to the `PATH` environment variable.

### Linux notes

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.

### OS X notes

Similar to Linux, but you probably won't need to use `sudo`.

## Command line arguments

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

### Options for `platform`
```
windows-x86
windows-x86_64
osx-x86_64
linux-x86
linux-x86_64
linux-arm
linux-armhf
```

### Usage
```
java -jar opencv-installer --version --platform --java --jni --headers --natives --overwrite
```

## Using the installer in Gradle build scripts

```groovy
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')
}
```

## Using the installer as Java library

First, add

```groovy
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:

```java
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()`