Loading...
Logo
Processing Forum
So, 

For a project to help people with disabilities perform simple computer vision actions using (M.Kinect) I'm hoping to get a processing sketch to work to identify mouse gestures first. In order to do this I've created a sketch with a 100 point array and the cursor motion across the screen will draw 99 points before it begins to "eat it's tail." I would simply like the sketch to recognize when a right angle is made or when two lines are drawn like so "=." 

I believe I need to work somehow with normalize but I'm missing a clear direction since there are really so many ways to do this. I know... it sounds like a newbie problem and it is... either way I'd really appreciate any help/direction/experience. 

Tis be for a good cause'

Here is current working code:


Copy code
  1. PVector[] positions;
    int maxpositions = 100;
    int currentposition = 0;


    //boolean right == false;
    //boolean left == false;


    void setup()
    {
      size(800, 600);

      positions = new PVector[maxpositions];
    }


    void draw()
    {
      background (255);

      positions[currentposition] = new PVector(mouseX, mouseY);

      currentposition++;

      if (currentposition >= 99)
      {
        // shuffle everything down
        for (int i = 1; i < currentposition; i++)
        {
          positions[i-1] = positions[i];
        }

        // stay at 99
        currentposition = maxpositions - 1;
      }


      for (int i = 0; i < currentposition; i++)
      {
        ellipse (positions[i].x, positions[i].y, 5, 5);  

        int sum = 0;
        sum += positions[i].x;
        
        if (i==(maxpositions-2)) {
        int avgSum;
        avgSum = sum/maxpositions;
        float xval;
        xval = (avgSum-positions[i-94].x);
    //    println ("average sum of array values = " + avgSum);
        
        
        if (xval>0) {
          background(0);
        }  
        if (xval<0) {
          background(255);
        }
        
        }
      
        


      }
      
      
    } 
THANK YOU! 

HUG!