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 & HelpPrograms › faceAPI & P5
Page Index Toggle Pages: 1
faceAPI & P5 (Read 645 times)
faceAPI & P5
Apr 12th, 2010, 5:28am
 
Hey there.

I've been trying to get faceAPI&Processing working via 6dofstreamer.

The program acquires the String stream sent by 6dofstreamer and parses it into separate fields so i can simply move around a rect via face tracking.

The problem is im getting "ArrayIndexOutOfBoundsException: 1" on line Code:
float secondNumber = Float.parseFloat(nums[1]); 



it throws the exception time to time not always. I guess its a problem with the str stream i get.

Should i put the lines dealing with acquiring&parsing data into a try&catch block? Would that solve the problem? And most importantly how ?

Heres the code:

Code:
 	

// Example by Tom Igoe

import processing.net.*;
Client myClient;
String inString;


void setup() {
 size (500, 500);

 // This example will not run if you haven't
 // previously started a server on this port
 myClient = new Client(this, "127.0.0.1", 29129);
}

void draw() {
 if (myClient.available() > 0) {
   background(0);
   inString = myClient.readString();
   String[] nums = split(inString, ' ');
   float firstNumber = Float.parseFloat(nums[0]);
   float secondNumber = Float.parseFloat(nums[1]);
   println(firstNumber);
   println(secondNumber);
   

   rect(firstNumber*-10,secondNumber*-10,20,20);
 }
}



My second question is: Is it possible to get multiple streams from a web cam?

Since faceAPI uses the web cam im not able to use it from processing as well. Thus i cant merge the real image with, say, a horse face!

Thx in advance.
Re: faceAPI & P5
Reply #1 - Apr 12th, 2010, 5:43am
 
Aerovisual wrote on Apr 12th, 2010, 5:28am:
it throws the exception time to time not always. I guess its a problem with the str stream i get.

Should i put the lines dealing with acquiring&parsing data into a try&catch block Would that solve the problem And most importantly how

Yes, it is related to the data you get.
And no, no need for try/catch, just test the result:
float secondNumber = 0;
if (nums.length > 1) secondNumber = float(nums[1]);

Re: faceAPI & P5
Reply #2 - Apr 12th, 2010, 5:44am
 
Now that makes sense =)

Thx for the quick reply.
Page Index Toggle Pages: 1