We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › reacTIVision  and Processing via OSCP5
Page Index Toggle Pages: 1
reacTIVision  and Processing via OSCP5 (Read 7954 times)
reacTIVision  and Processing via OSCP5
Dec 10th, 2005, 1:28am
 
Hi all

  The famous reacTIVision "robust tracking of fiducial markers in a real-time video stream" came out open source last week! Basicly, it track marker without any special camera system, Collect the video data and send it to the underlying applications layers through Open Sound Control. (One application for the tracking, one for the visual projection, PROCESSING!!!).

  Unfortunately, I'm not really comfortable with OSC. I found the www.sojamo.de Lib. It sounds interesting. I already did some Open Sound Control transfer from Max/MSP but I'm asking our community if somebody can help me to make the link between reacTIVision Tuio protocol using Open Sound Control and Processing. It sound really easy but again, I'm new in OSC and there is no information on reacTIVision and Processing.

There is the link to reacTIVision: http://www.iua.upf.es/mtg/reacTable/?software

There is some Java code that show how to Received and unpack OSC messages. I begin to cross that code to Processing. Any comments, news or help will be appreciate. We already did a Tangible interface like reacTable with Jitter but we want to move on a tracking fiducial markers system that use Processing for more power, less trouble and more fun. Jitter and flash was a.... experience. Don't try that at home.

Application Programming Interface:
----------------------------------
First you  need to create an instance of TuioClient. This class
is listening to TUIO messages on the specified port and generates
higher level messages based on the object events.

Your application needs to implement the TuioListener interface,
and has to be added to the TuioClient in order to receive messages.

A TuioListener needs to implement the following four methods:
* addTuioObj(int id):
 this is called when an object becomes visible
* removeTuioObj(int id):
 an object was removed from the table
* updateTuioObj(int id, etc.):
 the parameters of an object are updated
 these include the id and current position and orientation
* refresh():
 this method is called after each bundle,
 use it to repaint your screen for example


//********** TuioListener ****************
public interface TuioListener {

public void addTuioObj(int id);
public void updateTuioObj(int id, int c, float x, float y, float a, float X, float Y, float A, float m, float r);
public void removeTuioObj(int id);
public void refresh();
}

Divall

Thanks A Lot !!!
Re: reacTIVision  and Processing via OSCP5
Reply #1 - Dec 10th, 2005, 1:32am
 
The next step is the TuioClient / OSCListener  Class that talk to the TuioListener class.

//********** TuioClient ****************
import com.illposed.osc.*;
import java.util.*;

public class TuioClient implements OSCListener {

private int port = 3333;
private OSCPortIn oscPort;
private Vector objectList = new Vector();
private Vector newList = new Vector();

private int currentFrame = 0;
private int lastFrame = 0;

private Vector listenerList = new Vector();

public TuioClient(int port) {
this.port = port;
}

public TuioClient() {}

public void connect() {
try {
oscPort = new OSCPortIn(port);
oscPort.addListener("/tuio/2Dobj",this);
oscPort.startListening();
} catch (Exception e) {
System.out.println("failed to connect to port "+port);
}
}

public void disconnect() {
oscPort.stopListening();
try { Thread.sleep(100); }
catch (Exception e) {};
oscPort.close();
}

public void addTuioListener(TuioListener listener) {
listenerList.addElement(listener);
}

public void removeTuioListener(TuioListener listener) {
listenerList.removeElement(listener);
}

public void acceptMessage(Date date, OSCMessage message) {

Object[] args = message.getArguments();
String command = (String)args[0];

if ((command.equals("set")) && (currentFrame>=lastFrame)) {
int id  = ((Integer)args[1]).intValue();
int c   = ((Integer)args[2]).intValue();
float x = ((Float)args[3]).floatValue();
float y = ((Float)args[4]).floatValue();
float a = ((Float)args[5]).floatValue();
float X = ((Float)args[6]).floatValue();
float Y = ((Float)args[7]).floatValue();
float A = ((Float)args[8]).floatValue();
float m = ((Float)args[9]).floatValue();
float r = ((Float)args[10]).floatValue();

//System.out.println(id+" "+c+" "+x+" "+y+" "+a+" "+X+" "+Y+" "+A+" "+m+" "+r);
for (int i=0;i<listenerList.size();i++) {
TuioListener listener = (TuioListener)listenerList.elementAt(i);
if (listener!=null)
listener.updateTuioObj(c,c,x,y,a,X,Y,A,m,r);
}

} else if ((command.equals("alive")) && (currentFrame>=lastFrame)) {

for (int i=1;i<args.length;i++) {
// get the message content
newList.addElement(args[i]);
// reduce the object list to the lost objects
if (objectList.contains(args[i])) objectList.removeElement(args[i]);
else {
for (int j=0;j<listenerList.size();j++) {
TuioListener listener = (TuioListener)listenerList.elementAt(j);
if (listener!=null)
listener.addTuioObj(((Integer)args[i]).intValue());
}
}
}

// remove the remaining objects
for (int i=0;i<objectList.size();i++) {
int id  = ((Integer)objectList.elementAt(i)).intValue();
//System.out.println("remove "+id);
for (int j=0;j<listenerList.size();j++) {
TuioListener listener = (TuioListener)listenerList.elementAt(j);
if (listener!=null)
listener.removeTuioObj(id);
}
}

Vector buffer = objectList;
objectList = newList;

// recycling of the vector
newList = buffer;
newList.clear();

} else if (command.equals("fseq")) {
lastFrame = currentFrame;
currentFrame = ((Integer)args[1]).intValue();

if (currentFrame>lastFrame) {
for (int i=0;i<listenerList.size();i++) {
TuioListener listener = (TuioListener)listenerList.elementAt(i);
if (listener!=null) listener.refresh();
}
}
}
}
}

References:
-----------
This application uses the JavaOSC OpenSound Control library.
See http://www.mat.ucsb.edu/~c.ramakr/illposed/javaosc.html
for more information and the source code.

Thanks to reacTIVisionfor that great work.
http://www.iua.upf.es/mtg/reacTable/?software

DivAll
Re: reacTIVision  and Processing via OSCP5
Reply #2 - Dec 10th, 2005, 2:10pm
 
I'm looking at this too.

I can't offer much help at the moment, but will probably play with it over christmas.

I'm imagining we should be able to import the classes straight into Processing and then just implement the interface within the sketch to get direct acces to a Tuio object, much like they do in the demo app. The osc stuff is handled within that.

There is a pdf at http://www.iua.upf.es/mtg/reacTable/pdfs/GW2005-KaltenBoverBencinaConstanza.pdf
that documents the format of the information that is sent.

Unless you want to send stuff on to elsewhere it may not be necessary to get involved in the osc implementation at all.

Havent tried it yet thpough.

Cheers

Nick
Re: reacTIVision  and Processing via OSCP5
Reply #3 - Dec 15th, 2005, 2:00pm
 
Hi there,
I already have done a working reacTIVision demo for processing. It basically works the same way as the Java demo. The only thing you will need to implement are the addTuiObject, removeTuiObject, updateTuiObject and refresh methods which will be called when these events occur.

I will upload it at our page and on sourceforge today.
http://www.iua.upf.es/mtg/reacTable/?software

cheers,
Martin Kaltenbrunner
Music Technology Group
Barcelona, Spain
Re: reacTIVision  and Processing via OSCP5
Reply #4 - Dec 15th, 2005, 10:16pm
 
Thats grand - christmas really is arriving early this year, with the flurry of Processing releases and now this.

Thanks alot for releasing this and making it so simple to use. Looking forward to really playing with it now over christmas, rather than just getting it working.

I will raise a glass ortwo to you over the coming festivities.

Cheers

Nick
Re: reacTIVision  and Processing via OSCP5
Reply #5 - Jan 8th, 2006, 11:15pm
 
This may be more of an oscP5 questions than reactivision, but I will ask it here first.

I am using reactivision with Isadora, using Processing to translate the osc messages into the right format for Isadora to read.

I added the code in the osc examples into relevent tuio calls.

I have a sketch working on Mac feeding into isadora fine.

Have copied them all over onto a Windows machine and they don't work as they did on the mac.

The processing patch still reads the reactivison info ok, but once it is sent to the isadora patch it comes out as garbled numbers.

for example 11 comes out as 184549376.

If I run reactivison and the processing patch on the windows machine and send them to the izzy patch on a mac, it comes out fine.

If I send the info from processing on the pc or mac to izzy on the pc it comes out strange (I get  -.+(0)  from one float value).

I tried a test sketch that just sent a number to izzy on the pc and that workes fine, as does sending values backwards and forweards between instances of izzy on the two platforms.

I println the values just before they get sent out of processing and they are showing as the values they should be.

Anyone got any ideas what it might be or what else to check?

Cheers

Nick
Re: reacTIVision  and Processing via OSCP5
Reply #6 - Jan 9th, 2006, 2:32pm
 
hi nick,

you seem to have trouble with the different byte order
used to store numbers on the windows box, the mac and
the byte order used for transfer over the network.

while the mac use the big-endian byte order, the pc
uses the little-endian order.

the bit pattern of the "garbled" number 184549376
(assuming little-endian) is the counterpart to
the bit pattern of 11 (big-endian) and vice versa.

take a look at http://en.wikipedia.org/wiki/Endianness
for a more detailed description.

flo
Re: reacTIVision  and Processing via OSCP5
Reply #7 - Jan 10th, 2006, 6:43pm
 
I thought it might be something to do with endianess.

Its looking like a bug in Isadora rather than my end of stuff at the moment.

Thanks for your help.

Cheers

Nick
Re: reacTIVision  and Processing via OSCP5
Reply #8 - Sep 18th, 2009, 2:47am
 
@mkalten the link is dead

to get the proscessing implention for the reacTIVision better use the direct link:


http : // reactivision.sourceforge.net/

Maxx

sorry i cant post links in my first 5 posts  Angry
Page Index Toggle Pages: 1