BLUSHIF

Untitled

Nov 14th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import processing.net.*;
  2. import processing.video.*;
  3. import java.net.UnknownHostException;
  4. import java.net.InetAddress;
  5. Server s;
  6. Client c;
  7. String input;
  8. int incoming[];
  9. PImage vi;
  10. String HostName, HostAddress;
  11. Capture video;
  12. void setup() {
  13. size(640, 480);
  14. try {
  15. InetAddress addr = InetAddress.getLocalHost();
  16.  
  17. // Get IP Address
  18. byte[] ipAddr = addr.getAddress();
  19.  
  20. // Extract Just the IP. Vanilla addr returns name and address separated by a '/' character
  21. String raw_addr = addr.toString();
  22. String[] list = split(raw_addr, '/');
  23. HostAddress = list[1];
  24.  
  25. // Get hostname
  26. HostName = addr.getHostName();
  27. }
  28. catch (UnknownHostException e) {
  29. println(e);
  30. }
  31. println(HostName);
  32. println(HostAddress);
  33. background(204);
  34. video = new Capture(this, 640/2, 480/2);
  35. stroke(0);
  36. frameRate(5); // Slow it down a little
  37. s = new Server(this, 12345); // Start a simple server on a port
  38. video.start();
  39. }
  40. void draw() {
  41. for (int i = 0; i < video.pixels.length; i++) {
  42. s.write(video.pixels[i]);
  43. }
  44. video.resize(80, 60);
  45. image(video, 40, 30);
  46. c = s.available();
  47. if (c != null) {
  48. for (int i = 0; i < incoming.length; i++) {
  49. incoming[i]=int(c.readString());
  50. vi.pixels[i] = incoming[i];
  51. }
  52. image(vi, 0, 0);
  53. }
  54. }
Add Comment
Please, Sign In to add comment