GMU:(In)Visible Networks/Esra Demirel: Difference between revisions

From Medien Wiki
Line 88: Line 88:




==VIDEO IMPORT ON PROCESSING==


import oscP5.*;
import netP5.*;
import processing.video.*;
Movie myMovie;
OscP5 oscP5;
NetAddress myRemoteLocation; // IP of Computer running captury, Port configured in software


long lastMillis=0; // used to periodically send subscribe messages
==VIDEO IMPORT ON PROCESSING==
ArrayList <PVector> joints=new ArrayList <PVector>(); // used to buffer joint positions between oscEvent callbacks and "draw" calls


void setup() {
import oscP5.*;
fullScreen();
import netP5.*;
//size(800, 600);
import processing.video.*;
oscP5 = new OscP5(this, 1065);
Movie myMovie;
myRemoteLocation = new NetAddress("141.54.159.160", 1065); // our computer...
OscP5 oscP5;
NetAddress myRemoteLocation; // IP of Computer running captury, Port configured in software


myMovie = new Movie(this, "es.mov");
long lastMillis=0; // used to periodically send subscribe messages
myMovie.loop();
ArrayList <PVector> joints=new ArrayList <PVector>(); // used to buffer joint positions between oscEvent callbacks and "draw"        calls
}


void draw() {
void setup() {
// periodically ask the captury server to send us data.
fullScreen();
tint(255);
//size(800, 600);
image(myMovie, -400, -500);
oscP5 = new OscP5(this, 1065);
if (millis()-lastMillis>5000) {
myRemoteLocation = new NetAddress("141.54.159.160", 1065); // our computer...
// The format is as follows:
//"/subscribe/<Actor_name>/<skeleton_data_type>/<joint_name>/<data_format>"
//most of the placeholders can be replaced by a "*" for "everything"
// unfortunately, if you subscribe to too many things, a bug in the captury will lead to malformed OSC-bundles that in turn crash OSCP5


OscMessage myMessage = new OscMessage("/subscribe/*/blender/Head/vector"); // get positions ("vector") of all joints of actor "felix_braun_rot" in mm
myMovie = new Movie(this, "es.mov");
oscP5.send(myMessage, myRemoteLocation);
myMovie.loop();
}
}
for (int i=0; i<joints.size(); i++) {
//draw everything here
point(joints.get(i).x/5+width/2, joints.get(i).y/5+height/2);
}
joints.clear();
}


/*
void draw() {
strokeWeight(4);   
// periodically ask the captury server to send us data.
// go through list of joints and draw them all
tint(255);
frameRate(5);
image(myMovie, -400, -500);
fill(101, 50);
if (millis()-lastMillis>5000) {
stroke(255, 30);
// The format is as follows:
background(0);
//"/subscribe/<Actor_name>/<skeleton_data_type>/<joint_name>/<data_format>"
for (int i=0; i<joints.size(); i++) {
//most of the placeholders can be replaced by a "*" for "everything"
//draw everything here
// unfortunately, if you subscribe to too many things, a bug in the captury will lead to malformed OSC-bundles that in turn crash  OSCP5
point(joints.get(i).x/5+width/2, joints.get(i).y/5+height/2);
 
line(random(600), random(600), joints.get(i).x/5+width/2, joints.get(i).y/5+height/2);
OscMessage myMessage = new OscMessage("/subscribe/*/blender/Head/vector"); // get positions ("vector") of all joints of actor  "felix_braun_rot" in mm
}
oscP5.send(myMessage, myRemoteLocation);
joints.clear();
}
}*/
for (int i=0; i<joints.size(); i++) {
//draw everything here
point(joints.get(i).x/5+width/2, joints.get(i).y/5+height/2);
}
joints.clear();
}
 
/*
strokeWeight(4);   
// go through list of joints and draw them all
frameRate(5);
fill(101, 50);
stroke(255, 30);
background(0);
for (int i=0; i<joints.size(); i++) {
//draw everything here
point(joints.get(i).x/5+width/2, joints.get(i).y/5+height/2);
line(random(600), random(600), joints.get(i).x/5+width/2, joints.get(i).y/5+height/2);
}
joints.clear();
}*/
   
   
// Called every time a new frame is available to read
// Called every time a new frame is available to read
void movieEvent(Movie m) {
void movieEvent(Movie m) {
m.read();
m.read();
}
}
   
   


/* incoming osc message are forwarded to the oscEvent method. */
/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
void oscEvent(OscMessage theOscMessage) {
println(theOscMessage); // debug out
println(theOscMessage); // debug out
// only use packages that contain position data as three floats
// only use packages that contain position data as three floats
if (theOscMessage.checkTypetag("fff")) {
if (theOscMessage.checkTypetag("fff")) {
joints.add(new PVector(theOscMessage.get(0).floatValue(), theOscMessage.get(1).floatValue(), theOscMessage.get(2).floatValue()));
joints.add(new PVector(theOscMessage.get(0).floatValue(), theOscMessage.get(1).floatValue(),   theOscMessage.get(2).floatValue()));
println( theOscMessage.get(0).floatValue());
println( theOscMessage.get(0).floatValue());
println( theOscMessage.get(1).floatValue());
println( theOscMessage.get(1).floatValue());
println( theOscMessage.get(2).floatValue());
println( theOscMessage.get(2).floatValue());
}
}
}
}