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 & HelpOther Libraries › BVH integration
Page Index Toggle Pages: 1
BVH integration (Read 896 times)
BVH integration
Nov 6th, 2007, 10:00pm
 
Hi folks. I'm looking for a library or better  to import data from bvh files (motion capture files). I know someone wrote one a couple years ago but it's not working (called MotionData, I think) It's broken and I can't peak under the hood to repair or make it work with my files.

Does anyone experimented with bvh files in processing ?

Thanks !


Re: BVH integration
Reply #1 - Nov 7th, 2007, 6:13am
 
What's the problem? I am doing fine
Re: BVH integration
Reply #2 - Nov 7th, 2007, 8:42pm
 
Maybe it's just a newbie error, but here's the error message I get when I try to load my bvh file with the moD_demo.pde provided by Xer (http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_libraries_tools;action=display;num=1164867108;start=7#7)

Code:

java.lang.ArrayIndexOutOfBoundsException: 8

at BVH.ImportData(BVH.java:920)

at MotionData.<init>(MotionData.java:30)

at Temporary_9553_4774.setup(Temporary_9553_4774.java:37)

at processing.core.PApplet.handleDisplay(PApplet.java:1384)

at processing.core.PGraphics.requestDisplay(PGraphics.java:690)

at processing.core.PApplet.run(PApplet.java:1556)

at java.lang.Thread.run(Thread.java:613)

java.lang.ArrayIndexOutOfBoundsException: 8

at BVH.ImportData(BVH.java:920)

at MotionData.<init>(MotionData.java:30)

at Temporary_9553_4774.setup(Temporary_9553_4774.java:37)

at processing.core.PApplet.handleDisplay(PApplet.java:1384)

at processing.core.PGraphics.requestDisplay(PGraphics.java:690)

at processing.core.PApplet.run(PApplet.java:1556)

at java.lang.Thread.run(Thread.java:613)


Here's the source code of moD_Demo.pde:

Code:

import processing.opengl.*;
MotionData motion_data; // <==================== Add MoD library

int NumOfSegs;
int NumOfFrames;
int FrameRate;
static final int _W=1; // joint width
static final int _F=100; // joint scaler
static final int _NUM_FILES=1;
static final int _START_FILE=1;
double [][][]p0;
double [][][]p1;
boolean [][]isEP;
int f;

void setup()
{
String []filename=new String [_NUM_FILES];
int i;

// init frame number
f=0;

// set filenames list
//
// I'm not using this loop to load the bvh files.
//
/* for(i=0;i<_NUM_FILES;i++)
{
if((i+_START_FILE)<10)
filename[i]= "//bvh\\motion0"+(i+_START_FILE)+".bvh";
else
filename[i]= "C:\\bvh\\motion"+(i+_START_FILE)+".bvh";

System.out.println(filename[i]);
}*/
//
// Instead I put my url in the first position of the array. Is that what causes
// the error ? Doesn't seem so.
//
filename[0] = "azumi.bvh";

// startup a class
MotionData motion_data = new MotionData(filename);

// get info
NumOfSegs = motion_data.GetNumberOfSegments();
NumOfFrames = motion_data.GetNumberOfFrames();
FrameRate = motion_data.GetFrameRate();

System.out.println("Number of Segments ="+NumOfSegs);
System.out.println("Number of Frames ="+NumOfFrames);
System.out.println("Number of FrameRate ="+FrameRate);

// set frame rate
frameRate(FrameRate);

// setup joint data
p0 = new double [NumOfFrames][NumOfSegs][3];
p1 = new double [NumOfFrames][NumOfSegs][3];
isEP = new boolean [NumOfFrames][NumOfSegs];

for(f=0; f<NumOfFrames; f++)
motion_data.GetFrameObject(p0[f], p1[f], isEP[f], f);

// smooth out the motion
motion_data.FilterObject(p0,p1,NumOfSegs,NumOfFrames);

System.out.println("===========================");

size(1024, 768, OPENGL);
noStroke();
}

void draw()
{
double vx,vy,vz;
translate(width/2, height/2);

// color of joints
fill(0, 0, 0);
background(200);

// render the frame
if(f==NumOfFrames) f=0;
for(int i=0; i<NumOfSegs; i++)
{
beginShape(QUADS);
vx = _F*p0[f][i][0]; vy = _F*p0[f][i][1]-_W; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p0[f][i][0]; vy = _F*p0[f][i][1]+_W; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]; vy = _F*p1[f][i][1]+_W; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]; vy = _F*p1[f][i][1]-_W; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
endShape();
beginShape(QUADS);
vx = _F*p0[f][i][0]-_W; vy = _F*p0[f][i][1]; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p0[f][i][0]+_W; vy = _F*p0[f][i][1]; vz = _F*p0[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]+_W; vy = _F*p1[f][i][1]; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
vx = _F*p1[f][i][0]-_W; vy = _F*p1[f][i][1]; vz = _F*p1[f][i][2];
vertex((float)vx,(float)-vy,(float)vz);
endShape();
}

// update the next frame number
f++;
}


Finally, here's the bvh file I'm trying to load. It's a pretty long bvh file. http://www.glockenspiel.ca/transfert/azumi.bvh

Also, when I load the pde file, it automatically open an untitled sketch with it. Am I missing some files with it ?

Do you have a working example I could perhaps take a look at ?
Re: BVH integration
Reply #3 - Nov 8th, 2007, 2:26am
 
mmm... i think the lib is not perfect on the bvh you provided, i was using the bvh from http://www.e-motek.com/entertainment/downloads/index.html
, and I have retried their bvh file; it still fine.

Re: BVH integration
Reply #4 - Nov 8th, 2007, 3:25am
 
Yes indeed, it seems to problem is with my bvh file. I tried the e-motek example and it's doing fine. I'll look into my bvh file to see what's wrong, thanks !
Page Index Toggle Pages: 1