4

I'm trying to write a plugin for a Java Application. The plugin should be able to tell the Java Application that new events have been recognized (Observer Design Pattern, Polling ... thats not the point). The problem is that the events are tracked gestures coming from a Microsoft Kinect controller (I´m using C++ and the Microsoft Kinect SDK because I have to). So that means I have to communicate between the Java Application and my Kinect Application. I thought of something like an adapter design pattern where the Java application is "including" the interface (c++ header file, dll etc.). First I thought of JNI but then I have to write a DLL that will be used on both application sides, right? Another thing I thought of was to provide the gesture data via a protocol like UDP (or something more lightweight?). The last thing I heard of was to write a COM+ assembly ... but to be honest my knowledge about COM+ is rather little.

JAVA APPLICATION << ----- ??? ----- >> KINECT APPLICATION
seveves
  • 1,282
  • 4
  • 17
  • 37

3 Answers3

5

May be you should have a look at google's Protocol Buffers.

Since you are considering JNI. I'd suggest you refer to this IBM tutorial.

JNI allows the java application to call c/c++ methods and vice-versa.

Also have a look at this question, if you are calling java from c++.

Community
  • 1
  • 1
Sorter
  • 9,704
  • 6
  • 64
  • 74
3

I have found some examples such as here, here and here which recommend you either used a shared memory structure or else use sockets.

I think that in this case, letting your programs communicate through sockets would be the best idea since your applications will not be that tightly coupled, so you just need to expose an IP, a port and a set of commands.

According to this it seems possible to create a C++ server on the Kinect, but other than that I can't say much since I have never worked on Kinect related projects.

Community
  • 1
  • 1
npinti
  • 51,780
  • 5
  • 72
  • 96
  • Oh of course ... sockets! I gonna have a closer look on that. ty! – seveves Mar 09 '12 at 06:38
  • Works like a charm! I decided to use UDP ... seems fine ;) ... thanks! – seveves Mar 09 '12 at 17:32
  • @SeveFriede: Keep in mind that despite being faster, UDP does not guarantee the delivery of the package. This might be problematic if you decide to make your applications communicate over larger distances ;) – npinti Mar 09 '12 at 17:39
  • Thx for the hint! But at the moment the whole thing is running on a local machine ;) – seveves Mar 09 '12 at 17:42
0

JNI (Java Native Interface) allows the java application to call c/c++ methods.

All this requires that we have a means of communicating (Integrating Java with C++) between Java and C++. This is provided by the JNI (Java Native Interface).

For a practical example of using the JNI and calling native methods from Java, see this InfoWorld article.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
mkumar0304
  • 637
  • 7
  • 8