Skip to content

Commit

Permalink
* Document a bit the create() factory methods in the helper pack…
Browse files Browse the repository at this point in the history
…age of the OpenCV module, and their relationship with the `release()` methods

 * Upgrade presets for FlyCapture 2.7.3.13
  • Loading branch information
saudet committed Oct 26, 2014
1 parent cf68588 commit 905a586
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 43 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

* Document a bit the `create()` factory methods in the `helper` package of the OpenCV module, and their relationship with the `release()` methods
* Include new `createIndexer()` method in `CvMat`, `IplImage`, `Mat`, etc. for easy and efficient multidimensional access of data ([issue #317](http://code.google.com/p/javacv/issues/detail?id=317))
* Deprecate `get*Buffer()` methods in favor of a better named and generic `createBuffer()` method
* Fix `java.lang.UnsatisfiedLinkError` when allocating `opencv_core.Mat`, among others ([issue javacv:9](https://github.com/bytedeco/javacv/issues/9) and [issue javacv:28](https://github.com/bytedeco/javacv/issues/28))
* Force OpenCV to build with GCC 4.6, as newer versions are known to hang on Android 2.2 ([issue android:43819](https://code.google.com/p/android/issues/detail?id=43819))
* Upgrade presets for FFmpeg 2.4.2, LLVM 3.5.0, videoInput, where the latest code got merged into the master branch
* Upgrade presets for FFmpeg 2.4.2, FlyCapture 2.7.3.13, LLVM 3.5.0, and videoInput 0.200, where the latest code got merged into the master branch
* Add callbacks for Tesseract according to new functionality in JavaCPP
* Fix missing dependency of `opencv_contrib` on `opencv_nonfree`
* Skip functions that are not actually implemented in `avdevice`, causing load failures on Android
Expand Down
70 changes: 37 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ We can also have everything downloaded and installed automatically with:
}
```

* SBT (inside the `build.sbt` file)
* SBT (inside the `build.sbt` file)
```scala
classpathTypes += "maven-plugin"
libraryDependencies += "org.bytedeco.javacpp-presets" % moduleName % moduleVersion + "-0.9"
```

where the `moduleName` and `moduleVersion` variables correspond to the desired module. Additionally, we need to either set the `platform.dependency` system property (via the `-D` command line option) to something like `android-arm`, or set the `platform.dependencies` one to `true` to get all the binaries for Linux, Mac OS X, and Windows.
where the `moduleName` and `moduleVersion` variables correspond to the desired module. Additionally, we need to either set the `platform.dependency` system property (via the `-D` command line option) to something like `android-arm`, or set the `platform.dependencies` one to `true` to get all the binaries for Linux, Mac OS X, and Windows. On build systems where this does not work, we need to add the platform-specific artifacts manually.


Required Software
Expand All @@ -55,10 +55,43 @@ To use the JavaCPP Presets, you will need to download and install the following
* IBM JDK http://www.ibm.com/developerworks/java/jdk/ or
* Java SE for Mac OS X http://developer.apple.com/java/ etc.

Further, in the case of Android, the JavaCPP Presets also rely on:

* Android SDK API 8 or newer http://developer.android.com/sdk/


Manual Installation
-------------------
Simply put all the desired JAR files (`opencv*.jar`, `ffmpeg*.jar`, `flycapture*.jar`, `libdc1394*.jar`, `libfreenect*.jar`, `videoinput*.jar`, `artoolkitplus*.jar`, etc.), in addition to `javacpp.jar`, somewhere in your CLASSPATH. The JAR files available as pre-built artifacts are meant to be used with [JavaCPP](https://github.com/bytedeco/javacpp). They were built on Fedora 20, so they may not work on all distributions of Linux, especially older ones. The binaries for Android were compiled for ARMv7 processors featuring an FPU, so they will not work on ancient devices such as the HTC Magic or some others with an ARMv6 CPU. Here are some more specific instructions for common cases:

NetBeans (Java SE 6 or newer):

1. In the Projects window, right-click the Libraries node of your project, and select "Add JAR/Folder...".
2. Locate the JAR files, select them, and click OK.

Eclipse (Java SE 6 or newer):

1. Navigate to Project > Properties > Java Build Path > Libraries and click "Add External JARs...".
2. Locate the JAR files, select them, and click OK.

Eclipse (Android 2.2 or newer):

1. Follow the instructions on this page: http://developer.android.com/training/basics/firstapp/
2. Go to File > New > Folder, select your project as parent folder, type "libs/armeabi" as Folder name, and click Finish.
3. Copy `javacpp.jar`, `opencv.jar`, `ffmpeg.jar`, `artoolkitplus.jar`, etc. into the newly created "libs" folder.
4. Extract all the `*.so` files from `opencv-android-arm.jar`, `ffmpeg-android-arm.jar`, `artoolkitplus-android-arm.jar`, etc. directly into the newly created "libs/armeabi" folder, without creating any of the subdirectories found in the JAR files.
5. Navigate to Project > Properties > Java Build Path > Libraries and click "Add JARs...".
6. Select all of `javacpp.jar`, `opencv.jar`, `ffmpeg.jar`, `artoolkitplus.jar`, etc. from the newly created "libs" folder.

After that, we can access almost transparently the corresponding C/C++ APIs through the interface classes found in the `org.bytedeco.javacpp` package. Indeed, the `Parser` translates the code comments from the C/C++ header files into the Java interface files, (almost) ready to be consumed by Javadoc. However, since their translation still leaves to be desired, one may wish to refer to the original documentation pages. For instance, the ones for OpenCV and FFmpeg can be found online at:

* [OpenCV documentation](http://docs.opencv.org/)
* [FFmpeg documentation](http://ffmpeg.org/doxygen/)


Build Instructions
------------------
To rebuild the source code on the Java side, please note that the project files were created for:
If the binary files available above are not enough for your needs, you might need to rebuild them from the source code. To this end, the project files on the Java side were created for:

* Maven 2 or 3 http://maven.apache.org/download.html
* JavaCPP 0.9 https://github.com/bytedeco/javacpp
Expand All @@ -67,7 +100,7 @@ Each child module in turn relies on its corresponding native libraries being alr

* OpenCV 2.4.9 http://opencv.org/downloads.html
* FFmpeg 2.4.x http://ffmpeg.org/download.html
* FlyCapture 2.6.x http://ww2.ptgrey.com/sdk/flycap
* FlyCapture 2.7.x http://ww2.ptgrey.com/sdk/flycap
* libdc1394 2.1.x or 2.2.x http://sourceforge.net/projects/libdc1394/files/
* libfreenect 0.5 https://github.com/OpenKinect/libfreenect
* videoInput 0.200 https://github.com/ofTheo/videoInput/
Expand Down Expand Up @@ -116,35 +149,6 @@ Although JavaCPP can pick up native libraries installed on the system, the scrip
Thanks to Jose Gómez for testing this out!


Manual Installation
-------------------
Simply put all the desired JAR files (`opencv*.jar`, `ffmpeg*.jar`, `flycapture*.jar`, `libdc1394*.jar`, `libfreenect*.jar`, `videoinput*.jar`, and `artoolkitplus*.jar`, etc.), in addition to `javacpp.jar`, somewhere in your CLASSPATH. The JAR files available as pre-built artifacts are meant to be used with [JavaCPP](https://github.com/bytedeco/javacpp). They were built on Fedora 20, so they may not work on all distributions of Linux, especially older ones. The binaries for Android were compiled for ARMv7 processors featuring an FPU, so they will not work on ancient devices such as the HTC Magic or some others with an ARMv6 CPU. Here are some more specific instructions for common cases:

NetBeans (Java SE 6 or newer):

1. In the Projects window, right-click the Libraries node of your project, and select "Add JAR/Folder...".
2. Locate the JAR files, select them, and click OK.

Eclipse (Java SE 6 or newer):

1. Navigate to Project > Properties > Java Build Path > Libraries and click "Add External JARs...".
2. Locate the JAR files, select them, and click OK.

Eclipse (Android 2.2 or newer):

1. Follow the instructions on this page: http://developer.android.com/training/basics/firstapp/
2. Go to File > New > Folder, select your project as parent folder, type "libs/armeabi" as Folder name, and click Finish.
3. Copy `javacpp.jar`, `opencv.jar`, `ffmpeg.jar`, and `artoolkitplus.jar` into the newly created "libs" folder.
4. Extract all the `*.so` files from `opencv-android-arm.jar`, `ffmpeg-android-arm.jar`, and `artoolkitplus-android-arm.jar` directly into the newly created "libs/armeabi" folder, without creating any of the subdirectories found in the JAR files.
5. Navigate to Project > Properties > Java Build Path > Libraries and click "Add JARs...".
6. Select all of `javacpp.jar`, `opencv.jar`, `ffmpeg.jar`, and `artoolkitplus.jar` from the newly created "libs" folder.

After that, we can access almost transparently the corresponding C/C++ APIs through the interface classes found in the `org.bytedeco.javacpp` package. Indeed, the `Parser` translates the code comments from the C/C++ header files into the Java interface files, (almost) ready to be consumed by Javadoc. However, since their translation still leaves to be desired, one may wish to refer to the original documentation pages. For instance, the ones for OpenCV and FFmpeg can be found online at:

* [OpenCV documentation](http://docs.opencv.org/)
* [FFmpeg documentation](http://ffmpeg.org/doxygen/)


How Can I Help?
---------------
Contributions of any kind are highly welcome! At the moment, the `Parser` has limited capabilities, so I plan to improve it gradually to the point where it can successfully parse large C++ header files that are even more convoluted than the ones from OpenCV, but the build system could also be improved. Consequently, I am looking for help especially with the four following tasks, in no particular order:
Expand Down
6 changes: 3 additions & 3 deletions flycapture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Introduction
------------
This directory contains the JavaCPP Presets module for:

* FlyCapture 2.6.3.4 http://ww2.ptgrey.com/sdk/flycap
* FlyCapture 2.7.3.13 http://ww2.ptgrey.com/sdk/flycap

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.

Expand Down Expand Up @@ -35,12 +35,12 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.javacpp-presets.flycapture</groupId>
<artifactId>flycapture2test</artifactId>
<version>0.9</version>
<version>0.9.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>flycapture</artifactId>
<version>2.6.3.4-0.9</version>
<version>2.7.3.13-0.9.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Expand Down
2 changes: 1 addition & 1 deletion flycapture/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>flycapture</artifactId>
<version>2.7.3.8-${project.parent.version}</version>
<version>2.7.3.13-${project.parent.version}</version>
<packaging>jar</packaging>
<name>JavaCPP Presets for FlyCapture</name>

Expand Down
19 changes: 14 additions & 5 deletions flycapture/src/main/java/org/bytedeco/javacpp/FlyCapture2.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class FlyCapture2 extends org.bytedeco.javacpp.presets.FlyCapture2 {
//=============================================================================

//=============================================================================
// $Id: FlyCapture2Defs.h 200437 2014-06-27 22:00:28Z warrenm $
// $Id: FlyCapture2Defs.h 208258 2014-09-19 20:33:21Z erich $
//=============================================================================

// #ifndef PGR_FC2_FLYCAPTURE2DEFS_H
Expand Down Expand Up @@ -843,7 +843,7 @@ public class FlyCapture2 extends org.bytedeco.javacpp.presets.FlyCapture2 {
/** Network interface index used (or to use). */
public native @Cast("unsigned int") int networkInterfaceIndex(); public native GigEStreamChannel networkInterfaceIndex(int networkInterfaceIndex);
/** Host port on the PC where the camera will send the data stream. */
public native @Cast("unsigned int") int hostPost(); public native GigEStreamChannel hostPost(int hostPost);
public native @Cast("unsigned int") int hostPort(); public native GigEStreamChannel hostPort(int hostPort);
/** Disable IP fragmentation of packets. */
public native @Cast("bool") boolean doNotFragment(); public native GigEStreamChannel doNotFragment(boolean doNotFragment);
/** Packet size, in bytes. */
Expand All @@ -854,9 +854,12 @@ public class FlyCapture2 extends org.bytedeco.javacpp.presets.FlyCapture2 {
public native @ByRef IPAddress destinationIpAddress(); public native GigEStreamChannel destinationIpAddress(IPAddress destinationIpAddress);
/** Source UDP port of the stream channel. Read only. */
public native @Cast("unsigned int") int sourcePort(); public native GigEStreamChannel sourcePort(int sourcePort);
/** Host port on the PC where the camera will send the data stream.
This is deprecated, use hostPort instead. */
public native @Cast("unsigned int*") @ByRef IntPointer hostPost(); public native GigEStreamChannel hostPost(IntPointer hostPost);

public GigEStreamChannel() { allocate(); }
private native void allocate();
public GigEStreamChannel() { allocate(); }
private native void allocate();
}

/**
Expand Down Expand Up @@ -1995,7 +1998,13 @@ public class FlyCapture2 extends org.bytedeco.javacpp.presets.FlyCapture2 {

public AVIOption() { allocate(); }
private native void allocate();
}
}

/*@}*/

/*@}*/

// #pragma deprecated(hostPost)


// #endif // PGR_FC2_FLYCAPTURE2DEFS_H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public static abstract class AbstractCvPOSITObject extends Pointer {
public AbstractCvPOSITObject() { }
public AbstractCvPOSITObject(Pointer p) { super(p); }

/**
* Calls cvCreatePOSITObject(), and registers a deallocator.
* @return CvPOSITObject created. Do not call cvReleasePOSITObject() on it.
*/
public static CvPOSITObject create(CvPoint3D32f points, int point_count) {
CvPOSITObject p = cvCreatePOSITObject(points, point_count);
if (p != null) {
Expand All @@ -44,6 +48,9 @@ public static CvPOSITObject create(CvPoint3D32f points, int point_count) {
return p;
}

/**
* Calls the deallocator, if registered, otherwise has no effect.
*/
public void release() {
deallocate();
}
Expand All @@ -61,13 +68,21 @@ public AbstractCvStereoBMState() { }
return (CvStereoBMState)super.position(position);
}

/**
* Calls cvCreateStereoBMState(), and registers a deallocator.
* @return CvStereoBMState created. Do not call cvReleaseStereoBMState() on it.
*/
public static CvStereoBMState create(int preset, int numberOfDisparities) {
CvStereoBMState p = cvCreateStereoBMState(preset, numberOfDisparities);
if (p != null) {
p.deallocator(new ReleaseDeallocator(p));
}
return p;
}

/**
* Calls the deallocator, if registered, otherwise has no effect.
*/
public void release() {
deallocate();
}
Expand Down
Loading

0 comments on commit 905a586

Please sign in to comment.