Ask Your Question
2

How to contribute with a Java wrapper for native code functionality?

asked 2012-07-08 17:32:32 -0600

Rui Marques gravatar image

Is there a tutorial for someone who wants to contribute with some Java wrapping native code?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
4

answered 2012-07-09 03:33:21 -0600

Andrey Pavlenko gravatar image

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).

edit flag offensive delete link more
0

answered 2012-07-09 03:26:34 -0600

rics gravatar image

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.

edit flag offensive delete link more

Comments

Not sure that looking at JavaCV sources helps to contribute to OpenCV: they use different approaches for Java wrappers generation.

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2012-07-09 03:41:15 -0600 )edit

Unfortunately I even did not know that there is an OpenCV Java API so thanks for your answer. (I cannot upvote yet.) Is it the content of the mentioned opencv/modules/java/generator/src folder? Is there a reference/user docs about it?

rics gravatar imagerics ( 2012-07-09 04:34:08 -0600 )edit

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

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2012-07-09 06:37:47 -0600 )edit
1

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.

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2012-07-09 06:41:25 -0600 )edit

Great, thanks!

rics gravatar imagerics ( 2012-07-09 07:38:35 -0600 )edit
1

You can find Java API docs here: http://docs.opencv.org/java

AlexanderShishkov gravatar imageAlexanderShishkov ( 2012-07-09 19:18:01 -0600 )edit

Question Tools

Stats

Asked: 2012-07-08 17:32:32 -0600

Seen: 1,767 times

Last updated: Jul 09 '12