Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FlyCapture 2 C and C++ API. #6

Merged
merged 3 commits into from
Jul 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

* Make the `cppbuild.sh` scripts install native libraries inside the `cppbuild` subdirectories, instead of on the system
* Include new `platform.dependency` and `platform.dependencies` properties to let users depend easily on the artifacts that contain native libraries
* Add presets for FFTW 3.3.4, GSL 1.16
* Add presets for FFTW 3.3.4, GSL 1.16, LLVM 3.4.2
* Fix missing `static` keyword on methods annotated with an `@Adapter` ([issue #3](https://github.com/bytedeco/javacpp-presets/issues/3))
* Turn `Mat.createFrom()` into a static factory method, and make `Mat.copyFrom()` call `Mat.create()` as appropriate ([issue #1](https://github.com/bytedeco/javacpp-presets/issues/1))
* Add missing `native_camera` modules of `opencv_highgui` for Android
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ To rebuild the source code on the Java side, please note that the project files
* Maven 2 or 3 http://maven.apache.org/download.html
* JavaCPP 0.8 https://github.com/bytedeco/javacpp

Each child module in turn relies on its corresponding native library being installed in the directory specified in its `.java` configuration file or, by default, on the native system in `/usr/local/`, or `C:/MinGW/local/` (under Windows), or `${platform.root}/../local/` (for Android):
Each child module in turn relies on its corresponding native libraries being already installed in the `cppbuild` subdirectory by a prior execution of the included [CPPBuild Scripts](#cppbuild-scripts), explained below. To use native libraries already installed somewhere else on the system, other installation directories than `cppbuild` can also be specified in the `.java` configuration files directly. The following versions are supported:

* OpenCV 2.4.9 http://opencv.org/downloads.html
* FFmpeg 2.2.x http://ffmpeg.org/download.html
Expand All @@ -45,30 +45,31 @@ Each child module in turn relies on its corresponding native library being insta
* ARToolKitPlus 2.3.0 https://launchpad.net/artoolkitplus
* FFTW 3.3.4 http://www.fftw.org/download.html
* GSL 1.16 http://www.gnu.org/software/gsl/
* LLVM 3.4.2 http://llvm.org/releases/download.html

We can accomplish that with the included [CPPBuild Scripts](#cppbuild-scripts), explained below. Once everything installed, simply execute
Once everything installed and configured, simply execute
```bash
$ mvn install --projects opencv,ffmpeg,flycapture,libdc1394,libfreenect,videoinput,artoolkitplus,etc.
```
in the root directory, by specifying only the desired child modules in the command. Please refer to the comments inside the parent `pom.xml` file for further details.
inside the directory containing the parent `pom.xml` file, by specifying only the desired child modules in the command. Please refer to the comments inside the `pom.xml` file for further details.


CPPBuild Scripts
----------------
To build native libraries on the native C/C++ side, additional software is required:

* A recent version of Linux, Mac OS X, or Windows with MSYS and the Windows SDK
* Android NDK r7 or newer http://developer.android.com/sdk/ndk/
* Android NDK r7 or newer http://developer.android.com/sdk/ndk/ (required only for Android builds)

Then, execute:
With the above in working order, simply execute
```bash
$ ANDROID_NDK=/path/to/android-ndk/ bash cppbuild.sh [-platform <name>] [<install | clean>] [projects]
```
where platform includes: `android-arm`, `android-x86`, `linux-x86`, `linux-x86_64`, `macosx-x86_64`, `windows-x86`, `windows-x86_64`, etc.
where potential platform names include: `android-arm`, `android-x86`, `linux-x86`, `linux-x86_64`, `macosx-x86_64`, `windows-x86`, `windows-x86_64`, etc. (The `ANDROID_NDK` variable is required only for Android builds.)

To compile binaries for an Android device with no FPU, first make sure this is what you want. Without FPU, the performance of either OpenCV or FFmpeg is bound to be unacceptable. If you still wish to continue down that road, then replace "armeabi-v7a" by "armeabi" and "-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16" with "-march=armv5te -mtune=xscale -msoft-float", inside various files.

Although the scripts install the native libraries on the system to facilitate the build process, JavaCPP can at runtime load them from the JAR files created above by Maven, a useful feature for standalone applications or Java applets. Moreover, tricks such as the following work with JNLP:
Although JavaCPP can pick up native libraries installed on the system, the scripts exist to facilitate the build process across multiple platforms. They also allow JavaCPP to copy the native libraries and load them at runtime from the JAR files created above by Maven, a useful feature for standalone applications or Java applets. Moreover, tricks such as the following work with JNLP:
```xml
<resources os="Linux" arch="x86 i386 i486 i586 i686">
<jar href="lib/opencv-linux-x86.jar"/>
Expand Down Expand Up @@ -119,7 +120,7 @@ Contributions of any kind are highly welcome! At the moment, the `Parser` has li
* Improving the `Parser`
* Providing builds for more platforms, most notably `linux-arm`
* Replacing the Bash/Maven build combo by something better (Gradle?)
* Adding new presets as child modules for other C/C++ libraries (FFTW, GSL, LLVM, OpenNI, OpenMesh, PCL, Tesseract, etc.)
* Adding new presets as child modules for other C/C++ libraries (LLVM, OpenNI, OpenMesh, PCL, Tesseract, etc.)

To contribute, please fork and create pull requests, or post your suggestions [as a new "issue"](https://github.com/bytedeco/javacpp-presets/issues). Thank you very much in advance for your contribution!

Expand Down
29 changes: 15 additions & 14 deletions artoolkitplus/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,45 @@ fi
ARTOOLKITPLUS_VERSION=2.3.0
download https://launchpad.net/artoolkitplus/trunk/$ARTOOLKITPLUS_VERSION/+download/ARToolKitPlus-$ARTOOLKITPLUS_VERSION.tar.bz2 ARToolKitPlus-$ARTOOLKITPLUS_VERSION.tar.bz2

tar -xjvf ARToolKitPlus-$ARTOOLKITPLUS_VERSION.tar.bz2
patch -Np1 -d ARToolKitPlus-$ARTOOLKITPLUS_VERSION < ../ARToolKitPlus-$ARTOOLKITPLUS_VERSION.patch
mkdir ARToolKitPlus-$ARTOOLKITPLUS_VERSION/build_$PLATFORM
cd ARToolKitPlus-$ARTOOLKITPLUS_VERSION/build_$PLATFORM
mkdir -p $PLATFORM
cd $PLATFORM
tar -xjvf ../ARToolKitPlus-$ARTOOLKITPLUS_VERSION.tar.bz2 --exclude="*/id-markers/*"
cd ARToolKitPlus-$ARTOOLKITPLUS_VERSION
patch -Np1 < ../../../ARToolKitPlus-$ARTOOLKITPLUS_VERSION.patch

case $PLATFORM in
android-arm)
cmake -DCMAKE_TOOLCHAIN_FILE=android-arm.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$ANDROID_NDK/../local/" -DLIB_SUFFIX="/armeabi/" ..
cmake -DCMAKE_TOOLCHAIN_FILE=android-arm.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
make -j4
make install
;;
android-x86)
cmake -DCMAKE_TOOLCHAIN_FILE=android-x86.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$ANDROID_NDK/../local/" -DLIB_SUFFIX="/x86/" ..
cmake -DCMAKE_TOOLCHAIN_FILE=android-x86.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
make -j4
make install
;;
linux-x86)
CC="gcc -m32" CXX="g++ -m32" cmake -DCMAKE_BUILD_TYPE=Release -DLIB_SUFFIX=32 ..
CC="gcc -m32" CXX="g++ -m32" cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
make -j4
sudo make install
make install
;;
linux-x86_64)
cmake -DCMAKE_BUILD_TYPE=Release -DLIB_SUFFIX=64 ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
make -j4
sudo make install
make install
;;
macosx-x86_64)
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
make -j4
sudo make install
make install
;;
windows-x86)
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
nmake
nmake install
;;
windows-x86_64)
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
nmake
nmake install
;;
Expand Down
32 changes: 16 additions & 16 deletions artoolkitplus/src/main/java/org/bytedeco/javacpp/ARToolKitPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class ARToolKitPlus extends org.bytedeco.javacpp.presets.ARToolKitPlus {
static { Loader.load(); }

// Parsed from /home/saudet/projects/bytedeco/javacpp-presets/artoolkitplus/target/classes/org/bytedeco/javacpp/ARToolKitPlus_plus.h
// Parsed from ARToolKitPlus_plus.h

// #include <assert.h>
// #include <ARToolKitPlus/arBitFieldPattern.h>
Expand Down Expand Up @@ -52,7 +52,7 @@ public MultiTracker() { }



// Parsed from /usr/local/include/ARToolKitPlus/ARToolKitPlus.h
// Parsed from <ARToolKitPlus/ARToolKitPlus.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -144,7 +144,7 @@ public MultiTracker() { }
// #endif //__ARTOOLKITPLUS_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/config.h
// Parsed from <ARToolKitPlus/config.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -278,7 +278,7 @@ public MultiTracker() { }



// Parsed from /usr/local/include/ARToolKitPlus/ar.h
// Parsed from <ARToolKitPlus/ar.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -379,7 +379,7 @@ public MultiTracker() { }
// #endif //__ARTOOLKITAR_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/arMulti.h
// Parsed from <ARToolKitPlus/arMulti.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -462,7 +462,7 @@ public MultiTracker() { }
// #endif // __ARTOOLKITMULTI_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/matrix.h
// Parsed from <ARToolKitPlus/matrix.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -539,7 +539,7 @@ public MultiTracker() { }
// #endif // __ARTOOLKITMATRIX_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/vector.h
// Parsed from <ARToolKitPlus/vector.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -593,7 +593,7 @@ public MultiTracker() { }
// #endif // __ARTOOLKITVECTOR_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/Camera.h
// Parsed from <ARToolKitPlus/Camera.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -662,7 +662,7 @@ public MultiTracker() { }
// namespace ARToolKitPlus


// Parsed from /usr/local/include/ARToolKitPlus/extra/BCH.h
// Parsed from <ARToolKitPlus/extra/BCH.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -759,7 +759,7 @@ public MultiTracker() { }
// #endif // __BCH_CODE__H__


// Parsed from /usr/local/include/ARToolKitPlus/extra/Hull.h
// Parsed from <ARToolKitPlus/extra/Hull.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -838,7 +838,7 @@ public MultiTracker() { }
// #endif //__ARTOOLKITPLUS_HULL_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/extra/rpp.h
// Parsed from <ARToolKitPlus/extra/rpp.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -881,7 +881,7 @@ public static native void robustPlanarPose(@Cast("rpp_float*") @ByRef double[] e
// #endif // __LINK_WITH_RPP__


// Parsed from /usr/local/include/ARToolKitPlus/Tracker.h
// Parsed from <ARToolKitPlus/Tracker.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -1194,7 +1194,7 @@ private native void allocate(int imWidth, int imHeight, int maxImagePatterns/*=8
// #endif //__ARTOOLKIT_TRACKERIMPL_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/TrackerMultiMarker.h
// Parsed from <ARToolKitPlus/TrackerMultiMarker.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -1326,7 +1326,7 @@ private native void allocate(int imWidth, int imHeight, int maxImagePatterns/*=8
// namespace ARToolKitPlus


// Parsed from /usr/local/include/ARToolKitPlus/TrackerSingleMarker.h
// Parsed from <ARToolKitPlus/TrackerSingleMarker.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -1456,7 +1456,7 @@ private native void allocate(int imWidth, int imHeight, int maxImagePatterns/*=8
// namespace ARToolKitPlus


// Parsed from /usr/local/include/ARToolKitPlus/arBitFieldPattern.h
// Parsed from <ARToolKitPlus/arBitFieldPattern.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down Expand Up @@ -1544,7 +1544,7 @@ private native void allocate(int imWidth, int imHeight, int maxImagePatterns/*=8
// #endif //__ARBITFIELDPATTERN_HEADERFILE__


// Parsed from /usr/local/include/ARToolKitPlus/arGetInitRot2Sub.h
// Parsed from <ARToolKitPlus/arGetInitRot2Sub.h>

/**
* Copyright (C) 2010 ARToolkitPlus Authors
Expand Down
14 changes: 8 additions & 6 deletions cppbuild.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# Scripts to build and install native C++ libraries

set -eu

KERNEL=(`uname -s | tr [A-Z] [a-z]`)
ARCH=(`uname -m | tr [A-Z] [a-z]`)
case $KERNEL in
Expand Down Expand Up @@ -52,13 +54,13 @@ while [[ $# > 0 ]]; do
done
echo "Targeting platform \"$PLATFORM\""

if [[ -z "$OPERATION" ]]; then
if [[ -z ${OPERATION:-} ]]; then
echo "Usage: ANDROID_NDK=/path/to/android-ndk/ bash cppbuild.sh [-platform <name>] [<install | clean>] [projects]"
echo "where platform includes: android-arm, android-x86, linux-x86, linux-x86_64, macosx-x86_64, windows-x86, windows-x86_64, etc."
exit 1
fi

if [[ -z "$ANDROID_NDK" ]]; then
if [[ -z ${ANDROID_NDK:-} ]]; then
ANDROID_NDK=~/projects/android/android-ndk/
fi
export ANDROID_NDK
Expand All @@ -77,18 +79,18 @@ esac
function download {
COMMAND="curl -C - -L $1 -o $2"
echo "$COMMAND"
$COMMAND
$COMMAND || true
}

if [[ ${#PROJECTS[@]} -eq 0 ]]; then
PROJECTS=(opencv ffmpeg flycapture libdc1394 libfreenect videoinput artoolkitplus fftw gsl)
if [[ -z ${PROJECTS:-} ]]; then
PROJECTS=(opencv ffmpeg flycapture libdc1394 libfreenect videoinput artoolkitplus fftw gsl llvm)
fi

for PROJECT in ${PROJECTS[@]}; do
case $OPERATION in
install)
echo "Installing \"$PROJECT\""
mkdir $PROJECT/cppbuild
mkdir -p $PROJECT/cppbuild
cd $PROJECT/cppbuild
source ../cppbuild.sh
cd ../..
Expand Down
Loading