Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

gesture control interface

$
0
0
Hello everyone;
currently I'm making a gestural interface & for that I'm feeding a data from the Arduino serially to the  processing & making a blob for the tracking purpose. I need the mouse cursor to follow the blob . Down here is the code with out cursor following function.:

  1. import fullscreen.*;
  2. import processing.serial.*;
  3. FullScreen fs;
  4. Serial port;
  5. String X_data = "";
  6. String Y_data = "";
  7. String data = "";
  8.  
  9. int index= 0;
  10. int x = 0;
  11. int y = 0;
  12. PFont font;
  13. PImage img;
  14. void setup()
  15. {
  16.   size(1400, 770);
  17.  
  18.   fs = new FullScreen(this);
  19.   fs.enter();
  20.  
  21.   img = loadImage("heading.png");
  22.  
  23.   port = new Serial(this, "COM3", 9600);
  24.   port.bufferUntil('.');
  25.  
  26.   font = loadFont("AgencyFB-Reg-30.vlw");
  27.   textFont(font, 30);
  28.  
  29.   smooth();
  30.   noStroke();
  31. }
  32. void draw()
  33. {
  34.   //background(140, 140, 140);
  35.   background(0);
  36.  
  37.   //image(img, 25, 10, img.width/2, img.height/2);
  38.  
  39.  ////////////////////////////////////////////
  40.  
  41.   fill(30, 30, 30);
  42.   rect(20, 50, 260, 40);
  43.  
  44.   fill(255);
  45.   text("X : ", 45, 81);
  46.   fill(5, 130, 255);
  47.   text(x, 75, 82);
  48.  
  49.   fill(255);
  50.   text("Y : ", 165, 81);
  51.   fill(5, 130, 255);
  52.   text(y, 195, 82);
  53.  
  54.   fill(128, 0, 0);
  55.   ellipse(250, 70, 15, 15);
  56.  
  57.   fill(128, 0, 0);
  58.   ellipse(x, y, 15, 15);
  59. }
  60. void serialEvent (Serial port)
  61. {
  62.   data = port.readStringUntil('.');
  63.   data = data.substring(0, data.length() - 1);
  64.  
  65.   index = data.indexOf(",");
  66.   X_data = data.substring(0, index);
  67.   X_data = trim(X_data);
  68.   x = int(X_data);
  69.  
  70.   Y_data = data.substring(index+1, data.length());
  71.   Y_data = trim(Y_data);
  72.   y = int(Y_data);
  73. }
Can anybody help me with this?
Advanced thanks  

& here is the snap shot of the tracking interface:




Viewing all articles
Browse latest Browse all 1768

Trending Articles