Last active
July 24, 2017 08:19
-
-
Save narner/0e521f9d42aaa54a71816864b6a1e135 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.net.*; // include the networking library | |
Server server; // will receive predictions | |
String messageText; | |
PFont f; | |
void setup() | |
{ | |
fullScreen(P3D); | |
frameRate(600); | |
server = new Server(this, 5204); // listen on port 5204 | |
messageText = ""; | |
textAlign(CENTER); | |
fill(255); | |
f = createFont("Arial",48,true); // Arial, 16 point, anti-aliasing on | |
textFont(f, 120); | |
} | |
void draw() | |
{ | |
// check for incoming data | |
Client client = server.available(); | |
if (client != null) { | |
// check for a full line of incoming data | |
String line = client.readStringUntil('\n'); | |
if (line != null) { | |
println(line); | |
int val = int(trim(line)); // extract the predicted class | |
println(val); | |
if (val == 1) { | |
messageText = "Val 1"; | |
} else if (val == 2) { | |
messageText = "Val 2D"; | |
} else if (val == 3) { | |
messageText = "Val 3"; | |
} | |
} | |
} | |
// draw | |
background(0); | |
text(messageText, width/2, height/2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment