Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
58d13df
Fix the branch name.
May 20, 2014
8c850f7
Fork nu.pattern project to OpenPnP.
vonnieda Oct 15, 2015
20f1c5a
Working on updating to 2.4.11. Has OS X and Windows binaries so far.
vonnieda Oct 15, 2015
16c3058
Ignore Eclipse stuff.
vonnieda Oct 15, 2015
7096153
Merge branch 'master' into stable
vonnieda Oct 15, 2015
2b006b5
Accidentally built the OpenCV jars with 1.8 instead of 1.7, these are…
vonnieda Oct 16, 2015
366edb5
64 bit linux binary
vonnieda Oct 16, 2015
dcff1e1
Include releasing notes.
vonnieda Oct 16, 2015
dcbaf2e
Linux x64 binary and log, static this time.
vonnieda Oct 16, 2015
20d015e
Linux 32 bit binaries. Think that's it!
vonnieda Oct 16, 2015
1bf2350
Doc updates.
vonnieda Oct 16, 2015
6dd5228
Updated README to reflect fork info.
vonnieda Oct 16, 2015
697e3cd
no message
vonnieda Oct 16, 2015
4b0df62
Merge branch 'develop'
vonnieda Oct 16, 2015
ab68f7b
Accidentally left some merge conflict stuff in the readme.
vonnieda Oct 16, 2015
424aab9
Merge branch 'develop'
vonnieda Oct 16, 2015
2267120
Update travis for new branch names.
vonnieda Oct 16, 2015
74772e3
Add deploy plugins to pom.
vonnieda Oct 17, 2015
9943f4d
Add deploy plugins to pom.
vonnieda Oct 17, 2015
0e69db7
Add deploy plugins to pom.
vonnieda Oct 17, 2015
2a2536e
Merge branch '2.4.9-8'
vonnieda Oct 17, 2015
ba6341f
More info on releasing.
vonnieda Oct 17, 2015
724453a
Merge branch 'develop'
vonnieda Oct 17, 2015
d3889d0
First pass at update to 3.0.0. All binaries are built but tests on al…
vonnieda Oct 17, 2015
5ccd9e7
Adds x86 as a valid architecture identifier for 32 bit architectures.…
vonnieda Nov 20, 2015
73b0c78
Pull in some of the useful updates from the 3.0 branch:
vonnieda Nov 20, 2015
ebc53f6
Update versions for release of 2.4.11-2
vonnieda Nov 20, 2015
95d0c78
Merge branch 'develop'
vonnieda Nov 20, 2015
bcc325d
Add bundle plugin and packaging
Mar 7, 2016
e560631
Merge pull request #2 from nicolas-rempulski/develop
vonnieda Mar 8, 2016
d1906e3
Corrected a possessive pronoun spelling
Apr 30, 2016
569d4cb
Merge pull request #3 from mafagafogigante/minor-grammar-fix
vonnieda Apr 30, 2016
8f9fe92
Merge branch 'master' into develop
vonnieda May 3, 2016
6698609
Fix #5 by cleaning old opencv instances on start on Windows
phrack Aug 22, 2016
4697860
Merge pull request #9 from phrack/develop
vonnieda Aug 22, 2016
e148824
Release of 2.4.13-0
vonnieda Aug 22, 2016
836e047
Merge branch 'develop'
vonnieda Aug 22, 2016
367fbc9
3.2.0-0 build.
vonnieda Dec 27, 2016
f8f6443
Merge branch 'develop'
vonnieda Dec 27, 2016
fe2d69c
New version of linux x64 binaries built on Ubuntu 14.04.5, requires m…
vonnieda Dec 27, 2016
9674690
Added 32 bit binaries built in Ubuntu 14.04.5.
vonnieda Dec 27, 2016
9a50a9a
Prep for 3.2.0-1 release with updated Linux binaries./
vonnieda Dec 27, 2016
1ca7ca8
Merge branch 'develop'
vonnieda Dec 27, 2016
6ea1c62
Create CONTRIBUTING.md
vonnieda Feb 14, 2017
6ce3db9
Adding arch/linux binaries for Raspberry Pi
adambenhamo Jul 15, 2017
beae7ac
Updating release notes
adambenhamo Jul 17, 2017
0aae032
Correcting markdown mistakes
adambenhamo Jul 17, 2017
a25eb08
Merge pull request #22 from adambenhamo/RPiBinary
vonnieda Jul 18, 2017
8b5d8e2
Started integration work to get 3.4.2 released.
vonnieda Aug 4, 2018
9a33f4a
Prep release 3.4.2-0
vonnieda Aug 5, 2018
f4922d7
Merge branch 'feature/opencv-3.4.2' into develop
vonnieda Aug 5, 2018
b12001d
Merge branch 'develop'
vonnieda Aug 5, 2018
6764158
Better instructions for deploy.
vonnieda Aug 5, 2018
29f5eb0
Fixes library loading on JDK9+, including 10 and 11.
vonnieda Nov 17, 2018
fed49ee
Prep release 3.4.2-1
vonnieda Nov 17, 2018
5d56791
Merge branch 'develop'
vonnieda Nov 17, 2018
099fe37
fix typo with loadLocally() function in readme
snowe2010 Oct 23, 2019
20a5874
Merge pull request #47 from snowe2010/patch-1
vonnieda Oct 31, 2019
052ca2f
close inputstream
sirrrich Feb 12, 2020
a2b7d88
Merge pull request #50 from sirrrich/patch-1
vonnieda Feb 13, 2020
acb81f4
Prep release 3.4.2-2
vonnieda Feb 14, 2020
16c1ada
Merge branch 'develop'
vonnieda Feb 14, 2020
c0a925f
Update README.md
tech-consortium Mar 31, 2020
03c70bd
Prep release 4.3.0-0
vonnieda Apr 12, 2020
93057d4
Merge branch 'develop'
vonnieda Apr 12, 2020
3c769b2
Merge branch 'master' into openpnp-opencv-3.4.2-3
vonnieda Sep 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
.idea
settings.xml
target
.classpath
.project
.settings/org.eclipse.core.resources.prefs
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.m2e.core.prefs
opencv/**
.metadata/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
branches:
only:
- master
- stable
- develop

language: java

Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Issues, Bug Reports, and Feature Requests

* When creating a new Issue, first search to see if it has already been filed.
* Bug reports must include the following or will be deleted:
* Steps to reproduce.
* Expected result.
* Actual result.
* A Short, Self Contained, Correct, Example: http://sscce.org/
* Notes, log files, screen captures, videos, etc. to show the problem.

# Code Contributions and Pull Requests

Before starting work on a pull request, please read: https://github.com/openpnp/openpnp/wiki/Developers-Guide#contributing

Summary of guidelines:

* One pull request per issue, bug or feature.
* Describe the change in detail and why it is needed.
* Follow the coding style.
* Include tests and documentation.
* Run and pass the tests.
* Think of how this affects other users.
57 changes: 38 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
# OpenCV 2.4.9 (packaged by [Pattern](http://pattern.nu))

[![Build Status](https://travis-ci.org/PatternConsulting/opencv.svg?branch=master)](https://travis-ci.org/PatternConsulting/opencv)
# OpenCV 4.3.0 (packaged by [OpenPnP](http://openpnp.org))

[OpenCV](http://opencv.org) Java bindings packaged with native libraries, seamlessly delivered as a turn-key Maven dependency.

## Fork Notes

### Soft Fork

This is a soft fork of Pattern's OpenCV package at https://github.com/PatternConsulting/opencv.
That package has not been maintained in quite some time and I needed updated OpenCV
binaries for OpenPnP. I intend to maintain this fork for the foreseeable future
or until Pattern resumes maintenance of their package.

### Backwards Compatibility

I have left the source code packages and directories the same (nu.pattern)
and only changed the Maven coordinates in the pom.xml. This way the package
remains backwards compatible and it is very easy to switch between the
OpenPnP version and the Pattern version.

### Maven

To use this fork in your project, instead of the Pattern one, simply add
the same dependency but with the groupId org.openpnp instead of nu.pattern.

### Scala

I'm not uploading Scala artifacts as I don't know or use Scala. If someone
wants to maintain that portion of the package, let me know.

## Usage

### Project

Pattern's OpenCV package is added to your project as any other dependency.
OpenPnP's OpenCV package is added to your project as any other dependency.

#### [Maven](http://maven.apache.org/)

Expand All @@ -22,9 +46,9 @@ Pattern's OpenCV package is added to your project as any other dependency.
<!-- ... -->

<dependency>
<groupId>nu.pattern</groupId>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-7</version>
<version>4.3.0-0</version>
</dependency>

<!-- ... -->
Expand All @@ -36,16 +60,6 @@ Pattern's OpenCV package is added to your project as any other dependency.
</project>
```

#### [SBT](http://scala-sbt.org)

```scala
// ...

libraryDependencies += "nu.pattern" % "opencv" % "2.4.9-7"

// ...
```

### API

Typically, using the upstream [OpenCV Java bindings involves loading the native library](http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html#java-sample-with-ant) as follows:
Expand All @@ -62,7 +76,7 @@ This call will—exactly once per class loader—first attempt to load from the

This approach keeps most clients decoupled from Pattern's package and loader. As long as this is done sufficiently early in execution, any library using the OpenCV Java bindings can use the usual load call as documented by the OpenCV project.

There are, however, cases where Java class loaders are frequently changing (_e.g._, application servers, SBT projects, Scala worksheets), and [spurious attempts to load the native library will result in JNI errors](https://github.com/PatternConsulting/opencv/issues/7). As a partial work-around, this package offers an alternative API, [`nu.pattern.OpenCV.loadLocal()`](https://github.com/PatternConsulting/opencv/blob/master/src/main/java/nu/pattern/OpenCV.java), which—also exactly once per class loader—extracts the binary appropriate for the runtime platform, and passes it to `System#load(String)`. Ultimately, this may eventually load the library redundantly in the same JVM, which could be unsafe in production. Use with caution and understand the implications.
There are, however, cases where Java class loaders are frequently changing (_e.g._, application servers, SBT projects, Scala worksheets), and [spurious attempts to load the native library will result in JNI errors](https://github.com/PatternConsulting/opencv/issues/7). As a partial work-around, this package offers an alternative API, [`nu.pattern.OpenCV.loadLocally()`](https://github.com/PatternConsulting/opencv/blob/master/src/main/java/nu/pattern/OpenCV.java), which—also exactly once per class loader—extracts the binary appropriate for the runtime platform, and passes it to `System#load(String)`. Ultimately, this may eventually load the library redundantly in the same JVM, which could be unsafe in production. Use with caution and understand the implications.

It's recommended developers using any JNI library read further:

Expand All @@ -87,20 +101,25 @@ Producing native binaries is the most cumbersome process in maintaining this pac

The following platforms are supported by this package:

**IMPORTANT NOTE**: On Windows the Desktop Experience Feature is required because the opencv DLL is linked against several of the libraries provided by the Desktop Experience Feature. If the Desktop Experience Feature is not installed the opencv DLL will fail to load.

OS | Architecture
--- | ---
OS X | x86_32
OS X | x86_64
Linux | x86_64
Linux | x86_32
Windows | x86_32 (w/ Desktop Experience Feature)
Windows | x86_64 (w/ Desktop Experience Feature)

If you can help create binaries for additional platforms, please see notes under [_Contributing_](#contributing).

## Credits

This package is maintained by [Michael Ahlers](http://github.com/michaelahlers).
This package is maintained by [Jason von Nieda](http://github.com/vonnieda).

## Acknowledgements

- [Greg Borenstein](https://github.com/atduskgreg), who's advice and [OpenCV for Processing](https://github.com/atduskgreg/opencv-processing) project informed this package's development.
- [Michael Ahlers](http://github.com/michaelahlers), for originally creating and maintaining this project.
- [Greg Borenstein](https://github.com/atduskgreg), whose advice and [OpenCV for Processing](https://github.com/atduskgreg/opencv-processing) project informed this package's development.
- [Alex Osborne](https://github.com/ato), for helpful [utility class producing temporary directories with Java NIO that are properly garbage-collected on shutdown](https://gist.github.com/ato/6774390).
88 changes: 88 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Releasing a New Version

## Prepare

1. Download OpenCV Linux/OSX source and Windows binary release to opencv/. Should be a ZIP and a EXE.
2. Unzip source ZIP to create opencv/opencv-VERSION.
3. Run ./create-targets.sh VERSION (e.g. ./create-targets 3.0.0) to create all of the target directories under opencv/opencv-VERSION/target.
4. Update pom.xml, OpenCV.java and README.md with new versions.

## Build OSX and Java Targets

1. Make sure Java is 1.7: `java -version`, `export JAVA_HOME=$(/usr/libexec/java_home -v1.7)`
2. `cd opencv/opencv-VERSION/target/osx/x86_64`
3. `cmake -D BUILD_SHARED_LIBS=OFF -D WITH_EIGEN=OFF -D WITH_FFMPEG=OFF -D WITH_JAVA=ON ../../.. > cmake.log`
4. `make -j8`
5. `./copy-resources VERSION`. It won't finish, but it should get far enough.
6. `mvn clean test`.

## Build Linux Targets

```
sudo apt update -y
sudo apt full-upgrade -y
sudo reboot
sudo apt install default-jdk ant maven git cmake g++ open-vm-tools open-vm-tools-desktop -y
sudo reboot
sudo vmhgfs-fuse .host:/ /mnt/ -o allow_other -o uid=1000
cd /mnt/opencv/opencv/opencv-VERSION/target/linux/x86_64
cmake -D BUILD_SHARED_LIBS=OFF -D WITH_EIGEN=OFF -D WITH_FFMPEG=OFF -D WITH_JAVA=ON ../../.. > cmake.log
make -j8
```

## Linux/Arm for Raspberry Pi

* Install packages:
```
sudo apt-get update && sudo apt-get install oracle-java8-jdk cmake ant
sudo apt-get install build-essential cmake pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs libavcodec-dev libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils swig libv4l-0 libv4l-dev
```
* Change .bashrc to set JAVA_HOME, ANT_HOME and paths:

```
export ANT_HOME=/usr/share/ant/
export PATH=${PATH}:${ANT_HOME}/bin
export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
export PATH=$PATH:$JAVA_HOME/bin
```

* Download opencv:

```
wget https://github.com/opencv/opencv/archive/3.2.0.zip
mv 3.2.0 opencv.zip
unzip opencv.zip
cd opencv-3.2.0/
```

* Finally build using cmake:
```
mkdir build
cd build
cmake -D BUILD_SHARED_LIBS=OFF -D WITH_EIGEN=OFF -D WITH_FFMPEG=OFF -D WITH_JAVA=ON -D WITH_OPENCL=OFF -D BUILD_PERF_TESTS=OFF -D JAVA_INCLUDE_PATH=$JAVA_HOME/include -D JAVA_AWT_LIBRARY=$JAVA_HOME/jre/lib/amd64/libawt.so -D JAVA_JVM_LIBRARY=$JAVA_HOME/jre/lib/arm/server/libjvm.so -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
make install
```

* libopencv_java320.so can now be found in build/libs

## Unpack Windows Binaries

1. In a Windows VM, double click the Windows EXE downloaded previously. It will
ask where to extract. Choose opencv/opencv-VERSION/target/windows.
2. In the host OS, `./copy-resources VERSION`.
3. Back in the VM, `mvn clean test`

## Finish

1. Commit the updates to develop.
2. Merge develop into master.
3. Push to Sonatype:
1. Read http://central.sonatype.org/pages/apache-maven.html
2. `export GPG_TTY=$(tty)`
3. `mvn clean deploy -P release-sign-artifacts`
4. Check it's good at https://oss.sonatype.org/
5. Release with `mvn nexus-staging:release`
6. Or reset with `mvn nexus-staging:drop`
4. `git tag vVERSION-RELEASE` (e.g. `git tag v3.0.0-1`)

46 changes: 46 additions & 0 deletions copy-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
VERSION=$1
SHORT_VERSION=`echo $VERSION | tr -d .`
BASE_DIR=opencv/opencv-$VERSION

echo "Version: $VERSION"
echo "Short Version: $SHORT_VERSION"
echo "Base Dir: $BASE_DIR"

# Java
echo "Cleaning up Java..."
rm -f upstream/*.jar
rm -rf upstream/res/*
echo "Copying Java..."
cp $BASE_DIR/target/osx/x86_64/bin/opencv-$SHORT_VERSION.jar upstream
cp $BASE_DIR/target/osx/x86_64/java_test/build/jar/opencv-test.jar upstream
cp -r $BASE_DIR/target/osx/x86_64/java_test/res/* upstream/res

# OSX
echo "Cleaning up OSX..."
rm -f src/main/resources/nu/pattern/opencv/osx/x86_64/cmake.log
rm -f src/main/resources/nu/pattern/opencv/osx/x86_64/*.dylib
echo "Copying OSX..."
cp $BASE_DIR/target/osx/x86_64/cmake.log src/main/resources/nu/pattern/opencv/osx/x86_64
cp $BASE_DIR/target/osx/x86_64/lib/libopencv_java$SHORT_VERSION.dylib src/main/resources/nu/pattern/opencv/osx/x86_64

# Linux
echo "Cleaning up Linux x86_64..."
rm -f src/main/resources/nu/pattern/opencv/linux/x86_64/cmake.log
rm -f src/main/resources/nu/pattern/opencv/linux/x86_64/*.so
echo "Copying Linux x86_64..."
cp $BASE_DIR/target/linux/x86_64/cmake.log src/main/resources/nu/pattern/opencv/linux/x86_64
cp $BASE_DIR/target/linux/x86_64/lib/libopencv_java$SHORT_VERSION.so src/main/resources/nu/pattern/opencv/linux/x86_64

echo "Cleaning up Linux ARMv8..."
rm -f src/main/resources/nu/pattern/opencv/linux/ARMv8/*.so
echo "Copying Linux ARMv8..."
cp $BASE_DIR/target/linux/ARMv8/lib/libopencv_java$SHORT_VERSION.so src/main/resources/nu/pattern/opencv/linux/ARMv8

# Windows
echo "Cleaning up Windows..."
rm -f src/main/resources/nu/pattern/opencv/windows/x86_32/*.dll
rm -f src/main/resources/nu/pattern/opencv/windows/x86_64/*.dll
echo "Copying Windows..."
cp $BASE_DIR/target/windows/opencv/build/java/x86/opencv_java$SHORT_VERSION.dll src/main/resources/nu/pattern/opencv/windows/x86_32
cp $BASE_DIR/target/windows/opencv/build/java/x64/opencv_java$SHORT_VERSION.dll src/main/resources/nu/pattern/opencv/windows/x86_64

15 changes: 15 additions & 0 deletions create-targets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
VERSION=$1
SHORT_VERSION=`echo $VERSION | tr -d .`
BASE_DIR=opencv/opencv-$VERSION

echo "Version: $VERSION"
echo "Short Version: $SHORT_VERSION"
echo "Base Dir: $BASE_DIR"

mkdir $BASE_DIR/target
mkdir $BASE_DIR/target/linux
mkdir $BASE_DIR/target/linux/x86_64
mkdir $BASE_DIR/target/linux/ARMv8
mkdir $BASE_DIR/target/osx
mkdir $BASE_DIR/target/osx/x86_64
mkdir $BASE_DIR/target/windows
Loading