Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.net.*;
- import processing.video.*;
- import java.net.UnknownHostException;
- import java.net.InetAddress;
- Server s;
- Client c;
- String input;
- int incoming[];
- PImage vi;
- String HostName, HostAddress;
- Capture video;
- void setup() {
- size(640, 480);
- try {
- InetAddress addr = InetAddress.getLocalHost();
- // Get IP Address
- byte[] ipAddr = addr.getAddress();
- // Extract Just the IP. Vanilla addr returns name and address separated by a '/' character
- String raw_addr = addr.toString();
- String[] list = split(raw_addr, '/');
- HostAddress = list[1];
- // Get hostname
- HostName = addr.getHostName();
- }
- catch (UnknownHostException e) {
- println(e);
- }
- println(HostName);
- println(HostAddress);
- background(204);
- video = new Capture(this, 640/2, 480/2);
- stroke(0);
- frameRate(5); // Slow it down a little
- s = new Server(this, 12345); // Start a simple server on a port
- video.start();
- }
- void draw() {
- for (int i = 0; i < video.pixels.length; i++) {
- s.write(video.pixels[i]);
- }
- video.resize(80, 60);
- image(video, 40, 30);
- c = s.available();
- if (c != null) {
- for (int i = 0; i < incoming.length; i++) {
- incoming[i]=int(c.readString());
- vi.pixels[i] = incoming[i];
- }
- image(vi, 0, 0);
- }
- }
Add Comment
Please, Sign In to add comment