(→Demonstration) |
(→Let's Enjoy The Example File) |
||
Line 210: | Line 210: | ||
*Here is the complete code for this tutorial uploading on GitHub: [https://github.com/Yunbaby1028/WoolsWorld.git Complete Code of Wool's World]<br> | *Here is the complete code for this tutorial uploading on GitHub: [https://github.com/Yunbaby1028/WoolsWorld.git Complete Code of Wool's World]<br> | ||
*Example File including the movie is shared on Dropbox: [https://www.dropbox.com/sh/f8jcuw03nekoelz/AABeKONtJAI1vfNK4tWSZ3dTa?dl=0 Example File of Wool's World] | *Example File including the movie is shared on Dropbox: [https://www.dropbox.com/sh/f8jcuw03nekoelz/AABeKONtJAI1vfNK4tWSZ3dTa?dl=0 Example File of Wool's World] | ||
− | |||
== Demonstration == | == Demonstration == | ||
[http://www.example.com Demonstration Video of Controlling the Video in Processing with Captury] | [http://www.example.com Demonstration Video of Controlling the Video in Processing with Captury] |
Processing is usually used for the electronic arts, new media art and visual design.
If you want to have a creative work in processing with Captury, you need to receive the OSC[[OSC|Open Sound Control]] messages from the Captury and then use the data as the variable.
This includes OSC[[OSC|Open Sound Control]] with Processing and an example of controlling the video in Processing with Captury.
Follow this Step by Step tutorial for using PROCESSING to play the VIDEO with CAPTURY!
Data sending and receiving between the Captury and Processing over a network connection require OSC[[OSC|Open Sound Control]] (Open Sound Control) protocol. The following is the anatomy of OSC[[OSC|Open Sound Control]] in Processing.
PART 01 – Connect the Captury and Processing
int localport = 12000;
int remoteport = 1065; //Port number the Captury used to send messages
osc = new OscP5(this, localport);
remote = new NetAddress("kosmos.medien.uni-weimar.de", remoteport);
PART 02 – Receive data from the Captury
String skeleton1 = "LS"; //Skeleton name same with the Captury
String bone1 = "Root"; //The bone in use
void oscEvent(OscMessage msg) {
if(debug) {
print("### received an osc message.");
print(" addrpattern: "+msg.addrPattern());
println(" typetag: "+msg.typetag());
}
}
void refreshSubscriptions() {
subscribeBone(skeleton1, bone1);
}
if (frameCount % 10 == 0) {
refreshSubscriptions();
}
void subscribeBone(String skeletonId, String bone) {
OscMessage msg = new OscMessage("/subscribe/" + skeletonId + "/blender/" + bone + "/vector"); //Create OSC message
msg.add(50.0); //Add a float to the OSC message
msg.add(0.0);
msg.add(100.0);
osc.send(msg, remote); //Send the message
}
PART 03 – Pass data to the object
void plugBone(Object target, String skeleton, String bone) {
String path = "/" + skeleton + "/blender/" + bone + "/vector";
osc.plug(target, "update" + bone, path);
}
Sphere sphere1;
sphere1 = new Sphere(1);
sphere1.draw();
plugBone(sphere1, skeleton1, bone1);
PART 04 – Use the data as a variable
float x, y, z;
public void updateRoot(float x, float y, float z) {
this.x = map(x, 0, 100, -width/2, width/2);
this.y = map(y, -100, 100, -height/2, height/2);
this.z = map(z, 0, 100, 0, depth);
}
Then you can have a sphere moving follow the data from the Captury! For further application, you can use x, y, z to control whatever you want in Processing!
Since we can successfully use the data from the capture, it can be creatively to use the position of the object to control whatever you want in Processing!
The following is an example of using position values to play or reverse the video and change the play speed of the video.
PART 01 – Play a video in Processing
import processing.video.*; //Import libraries
Movie myMovie; //Declare a object as Movie
void setup() {
size(1920, 1080); //or use 'fullScreen(P3D);'
frameRate(60);
background(0);
myMovie = new Movie(this, "Chinese Knot_Final.mov"); //Load a movie, normally followed with 'play()' or 'loop()'
}
void draw() {
image(myMovie, 0, 0, width, height); //Position to put the movie
}
void movieEvent(Movie m) {
m.read();
}
PART 02 – Play or reverse the video and change the play speed
int play; //Declare a value to judge play or reverse the video
int getLength() {
return int(myMovie.duration() * myMovie.frameRate);
}
int getFrame() {
return ceil(myMovie.time() * 60) - 1;
}
if(x < -50 && getFrame() < (getLength() - 1)){
play = 1;
myMovie.play();
}
else {
play = -1;
myMovie.play();
}
float newSpeed = map(abs(y)/10, 0, 150, 0*play, 2*play); //abs() to have absolute position value
myMovie.speed(newSpeed);
Thanks for your attention to this tutorial, and feel free to debug and improve it.
Demonstration Video of Controlling the Video in Processing with Captury