How to contribute with a Java wrapper for native code functionality?
Is there a tutorial for someone who wants to contribute with some Java wrapping native code?
Is there a tutorial for someone who wants to contribute with some Java wrapping native code?
OpenCV Java API consists of hundreds thin wrappers to native OpenCV functions. Most of these wrappers are generated automatically at build time, and just a small part of them is written manually. (BTW the same approach is used for OpenCV Python API.) Most of OpenCV Java classes (except primitive ones like Point, Rect, Scalar, etc) keep just an address of the corresponding native object and use it for calls to native methods. The Mat class is wrapped manually but it still keeps all the data in native.
Not all the OpenCV classes and functions are ported to Java, just a subset of most important ones and those that have easy-to-port API.
Generally, a program that extensively uses OpenCV should do it in native level that allows access to all the C/C++ library API and eliminates overhead of numerous JNI calls.
So, turning back to the unoriginal question, the answer depends on the functionality to wrap: it might happen that that the function can be ported automatically after some improvements in the wrappers generator script or it may be more sensible adding another manual wrapper like ones stored under opencv/modules/java/generator/src folder.
So please open a feature request at OpenCV tracker and we'll suggest a recommended way to contribute a new warapper(s).
You may try JavaCV. It provides a Java wrapper to OpenCV and to other libraries.
Although it is not a tutorial you can check the source for details.
Not sure that looking at JavaCV sources helps to contribute to OpenCV: they use different approaches for Java wrappers generation.
Since v 2.3.1 OpenCv for Android package includes Java API that provides a hundreds of thin auto-generated wrappers to C++ functions. Some important stuff cannot be ported automatically, so it's ported manually (modules/gava/generator/src). You're correct that Java API is not mentioned in OpenCV documentation (at docs.opencv.org), but if you download package for Android from SourceForge you'll find there self-documented Eclipse library project (javadoc in code allows Eclipse to provide help in code editor) as well as html docs on Java API at OpenCV-2.4.2-android-sdk/sdk/ava/javadoc/index.html
When you browse OpenCV reference at docs.opencv.org there is a hint how to guess if some particulat function is wrapped to Java: if there is a Python version of the function started from 'cv2.' then it exists in Java as well. This is because Python wrappers generator shares some code with Java wrappers generator.
You can find Java API docs here: http://docs.opencv.org/java
Asked: 2012-07-08 17:32:32 -0600
Seen: 1,767 times
Last updated: Jul 09 '12
Unresolved inclusion in OpenCV+Android tutorial
android: how to put a column into Mat
OpenCV Tutorial 1 - Add OpenCV on API 8
Running the OpenCV4Android application on my PC
cvGetSpatialMoment JAVA equivalent
How to get good matches from the ORB feature detection algorithm?
How to decrease the number of processed frames from a live video camera?