Webcam example:
float p1 = 0.5; float p2 = 0.5; float p3 = 0.5; //Necessary for OSC communication with Wekinator: import oscP5.*; import netP5.*; OscP5 oscP5; NetAddress dest; void setup() { size(640, 360, P2D); colorMode(HSB); //Initialize OSC communication oscP5 = new OscP5(this, 12000); //listen for OSC messages on port 12000 (Wekinator default) dest = new NetAddress("127.0.0.1", 6448); //send messages back to Wekinator on port 6448, localhost (this machine) (default) rectMode(CENTER); noStroke(); } void draw() { background(255); float x = width*p1; float y = height*p2; float colour = 255*p3; fill(colour, 255, 255); rect(x, y, 50, 50); } //This is called automatically when OSC message is received void oscEvent(OscMessage theOscMessage) { if (theOscMessage.checkAddrPattern("/wek/outputs")==true) { if (theOscMessage.checkTypetag("fff")) { //Now looking for 2 parameters p1 = theOscMessage.get(0).floatValue(); //get this parameter p2 = theOscMessage.get(1).floatValue(); //get 2nd parameter p3 = theOscMessage.get(2).floatValue(); //get third parameters println("Received new params value from Wekinator"); } else { println("Error: unexpected params type tag received by Processing"); } } }