Exemple #1
0
        void pointCtrl_PointCreate(object sender, HandEventArgs e)
        {
            //  Console.WriteLine("Created..\n");

            handPoint   = depthGen.ConvertRealWorldToProjective(e.Hand.Position);
            handPoint   = e.Hand.Position;
            handPoint.Y = -handPoint.Y;
            //   handPoint = depthGen.ConvertProjectiveToRealWorld(e.Hand.Position);

            HandPointContact hdc = new HandPointContact(e.Hand.ID, (int)((handPoint.X * scrWidth) / xRes), (int)(((handPoint.Y) * scrHeight) / yRes), Multitouch.Contracts.ContactState.Removed);

            hdc.RowPoint      = handPoint;
            hdc.prev_RowPoint = handPoint;
            hdc.OriginPoint   = new System.Windows.Point(hdc.RowPoint.X, hdc.RowPoint.Y);
            hdc.timestamp     = e.Hand.Time;
            // HandPointContact hdc = new HandPointContact(e.Hand.ID, (int)(handPoint.X ), (int)((handPoint.Y) ), Multitouch.Contracts.ContactState.New);

            HandPointBuffer.Add(hdc);
            for (int i = 0; i < 5; i++)
            {
                pbuffer[i]    = new Point((int)hdc.Position.X, (int)hdc.Position.Y);
                point_counter = 1;
            }

            inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Removed);
            pointCollections.Add(new PointStatus(hdc));
            PointStatus pt = pointCollections[hdc.Id];

            Console.WriteLine("Created" + e.Hand.ID.ToString() + " Hello  Time:\n" + e.Hand.Time.ToString());
        }
Exemple #2
0
        //needs improvement
        void relativemotion(Point3D updatedhandPoint, HandPointContact hdc)
        {
            double diffx = (updatedhandPoint.X - hdc.RowPoint.X) * (scrWidth / ((scrWidth * 1) / 2));
            double diffy = (updatedhandPoint.Y - hdc.RowPoint.Y) * (scrHeight / ((scrHeight * 1) / 2));

            hdc.accelerationx = diffx - hdc.velocityx;
            hdc.velocityx    += hdc.accelerationx;
            hdc.accelerationy = diffy - hdc.velocityy;
            hdc.velocityy    += hdc.accelerationy;
            //double scrdiffx = (((scrWidth/) * Math.Pow(diffx,1.5)) / Math.Pow(50,1.5));
            //   double scrdiffy = (((scrHeight/4) * Math.Pow(diffy,1.5)) / Math.Pow(50,1.5));

            PointStatus pt = pointCollections[hdc.Id];

            hdc.RowPoint = updatedhandPoint;

            /*   if (pt.is_non_steady == true)
             * {
             *     pt.nonsteady_counter++;
             *     if (pt.nonsteady_counter < 11)
             *     {
             *
             *         pt.Location = new Point((int)(pt.Location.X + hdc.velocityx * (1 - (1 / pt.nonsteady_counter))), (int)(pt.Location.Y + hdc.velocityy * (1 - (1 / pt.nonsteady_counter))));
             *     }
             *     else
             *     {
             *         pt.is_non_steady = false;
             *         pt.nonsteady_counter = 0;
             *     }
             *
             * }
             * else
             * {
             *     pt.Location = new Point((int)(pt.Location.X + hdc.velocityx ), (int)(pt.Location.Y + hdc.velocityy ));
             * }*/
            double xval = pt.Location.X + hdc.velocityx;
            double yval = pt.Location.Y + hdc.velocityy;

            if (xval < 0)
            {
                xval = 0;
            }
            if (yval < 0)
            {
                yval = 0;
            }
            pt.Location = new Point((int)(xval), (int)(yval));
            if (hdc.State == Multitouch.Contracts.ContactState.New || hdc.State == Multitouch.Contracts.ContactState.Moved)
            {
                hdc.Update((int)pt.Location.X, (int)pt.Location.Y, Multitouch.Contracts.ContactState.Moved);
                inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Moved);
                //System.Console.WriteLine("Moving..");
                //pt.SetColor(Brushes.Red);
            }

            /*if (pt.is_non_steady == false)
             * {
             *  grab_gesture(hdc, pt);
             * }*/
        }
Exemple #3
0
        void steadydetector_NotSteady(object sender, SteadyEventArgs e)
        {
            // System.Console.WriteLine("NotSteday..");
            PointStatus pt = pointCollections[e.ID];

            // if ( pt.is_non_steady==false)
            {
                // pt.nonsteady_counter = 0;
                if (pt.is_clicked == true)
                {
                    pt.SetColor(Brushes.Red);
                }
                else
                {
                    pt.SetColor(Brushes.Green);
                }
                pt.is_non_steady = true;
                pt.is_triggered  = true;
                System.Console.WriteLine("Hand is moving..:");
            }
            //flrouter.ActiveListener = pointCtrl;
            if (is_steady == 1)
            {
                is_push_allow_counter = 0;
                is_push_allow         = 1;
                is_steady             = 0;
            }
        }
Exemple #4
0
        void pointCtrl_PointDestroy(object sender, IdEventArgs e)
        {
            lock (this)
            {
                for (int i = 0; i < HandPointBuffer.Count; i++)
                {
                    HandPointContact hdc = HandPointBuffer[i] as HandPointContact;
                    if (hdc.Id == e.ID)
                    {
                        hdc.destroy();
                        PointStatus pt = pointCollections[e.ID];


                        pointCollections.Remove(e.ID);
                        pt.destroy();
                        inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Removed);
                        break;
                    }
                }

                Console.WriteLine("Destroyed" + e.ID.ToString() + "\n");
            }
        }
Exemple #5
0
        //Unused  ..
        void smoothenCursorMovement(Point3D updatedhandPoint, HandPointContact hdc)
        {
            /*    if (is_steady == 1)
             *  {
             *
             *      if (steady_counter > 10)
             *      {
             *
             *      }
             *      is_push_allow_counter = 0;
             *      is_push_allow = 1;
             *      is_steady = 0;
             *  steady_counter++;
             *  }*/

            System.Windows.Point center = hdc.OriginPoint;
            int         deskHeight      = scrHeight;
            int         deskWidth       = scrWidth;
            int         h_x             = 0;
            int         h_y             = 0;
            double      power           = 1.7;
            PointStatus pt = pointCollections[hdc.Id];

            h_x = (int)(updatedhandPoint.X - (center.X - 100));
            h_y = (int)(updatedhandPoint.Y - (center.Y - 100));

            if (h_x < 0)
            {
                h_x = 0;
            }
            if (h_y < 0)
            {
                h_y = 0;
            }

            int x = 0;
            int y = 0;

            x = h_x * deskWidth / 200;
            y = h_y * deskHeight / 200;
            if (is_steady == 1)
            {
                // Console.WriteLine("Steady...");
            }

            /* if (pt.is_non_steady == true)
             * {
             *   double diffx = updatedhandPoint.X - hdc.Position.X;
             *   double diffy = updatedhandPoint.Y - hdc.Position.Y;
             *   if (Math.Abs(diffx) < 5 && Math.Abs(diffy) < 5)
             *   {
             *       return;
             *   }
             *   else
             *   {
             *       pt.is_non_steady = false;
             *   }
             * }*/
            hdc.RowPoint = updatedhandPoint;

            /*      if (pt.is_non_steady == true )
             * {
             *
             *    pt.nonsteady_counter++;
             * //     System.Console.WriteLine(pt.nonsteady_counter);
             * //   pt.SetColor(Brushes.BlueViolet);
             *    if (pt.nonsteady_counter > 10)  //stop looking for gesture
             *    {
             *        pt.nonsteady_counter = 0;
             *        // pt.gesture_start = false;
             *        pt.is_non_steady = false;
             *        //System.Console.WriteLine("Grab Session Ended");
             *        if (pt.is_clicked == true)
             *        {
             *            pt.SetColor(Brushes.Red);
             *        }
             *        else
             *        {
             *            pt.SetColor(Brushes.Green);
             *        }
             *    }
             *   if(pt.nonsteady_counter<5)
             *    {
             *        return;
             *    }
             *   if (pt.nonsteady_counter > 7 && pt.nonsteady_counter < 10)
             *   {
             *       x = (x + pt.Location.X )/ 2;
             *       y = (y + pt.Location.Y )/ 2;
             *   }
             * }*/
            /*    clipHandFromDepthMap(updatedhandPoint);
             *  if (is_steady == 1)
             *  {
             *
             *  }
             *  int status = openpalm.isDetected(clipping, updatedhandPoint);
             *  if (status == 1)
             *  {
             *      //System.Console.WriteLine("open Palm");
             *  }
             *  else if (status == 2)
             *  {
             *     // System.Console.WriteLine("Close Plam");
             *  }
             *  else
             *  {
             *      System.Console.WriteLine("unknown");
             *  }*/

            double avgx = x;
            double avgy = y;



            pt.Location = new System.Drawing.Point((int)avgx, (int)avgy);
            if (hdc.State == Multitouch.Contracts.ContactState.New || hdc.State == Multitouch.Contracts.ContactState.Moved)
            {
                hdc.Update((int)avgx, (int)avgy, Multitouch.Contracts.ContactState.Moved);
                inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Moved);
                //System.Console.WriteLine("Moving..");
                //pt.SetColor(Brushes.Red);
            }
            // x = ((int)((Math.Pow(h_x, power) * (deskWidth )) / Math.Pow(200, power)));
            // y = ((int)((Math.Pow(h_y, power) * (deskHeight)) / Math.Pow(200, power)));

            /* if (h_x < change_point)
             * {
             *    x = ((int)((Math.Pow(h_x, power) * (deskWidth*2)) / Math.Pow(200, power)));
             * }
             * else
             * {
             *    x = ((int)((Math.Pow(h_x, (1/power)) * (deskWidth)) / Math.Pow(200, (1/power))));
             * }
             * if (h_y < change_point)
             * {
             *    y = ((int)((Math.Pow(h_y, power) * (deskHeight)*2) / Math.Pow(200, power)));
             * }
             * else
             * {
             *    y = ((int)((Math.Pow(h_y,(1/ power)) * (deskHeight)) / Math.Pow(200, (1/power))));
             * }*/

// Do not delete

            /*
             * double avgx = x;
             * double  avgy = y;
             *
             * if (is_push_allow == 1 & is_push==0)
             * {
             *
             *
             *  if (is_push_allow_counter > 3)
             *  {
             *      is_push_allow = 0;
             *     //flrouter.ActiveListener = null;
             *      if (hdc.State == Multitouch.Contracts.ContactState.Removed)
             *      {
             *          pt.SetColor(Brushes.Green);
             *      }
             *      else
             *      {
             *          pt.SetColor(Brushes.Red);
             *      }
             *  }
             *  is_push_allow_counter++;
             *  return;
             *
             * }
             * if (is_push == 1 && is_push_stable==0)
             * {
             *
             *  return;
             *
             * }
             *
             * hdc.RowPoint = updatedhandPoint;
             *
             *
             *  pt.Location = new System.Drawing.Point((int)avgx, (int)avgy);
             *
             *  //bool status = openpalm.isDetected(clipping, updatedhandPoint);
             *  if (hdc.State == Multitouch.Contracts.ContactState.New || hdc.State == Multitouch.Contracts.ContactState.Moved)
             *  {
             *      hdc.Update((int)avgx, (int)avgy, Multitouch.Contracts.ContactState.Moved);
             *      inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Moved);
             *    //System.Console.WriteLine("Moving..");
             *      //pt.SetColor(Brushes.Red);
             *  }
             */
        }
Exemple #6
0
        void steadydetector_Steady(object sender, SteadyEventArgs e)
        {
            //   System.Console.WriteLine("Steady Detected..");
            PointStatus      pt  = pointCollections[e.ID];
            HandPointContact hdc = null;

            is_steady = 1;
            for (int i = 0; i < HandPointBuffer.Count; i++)
            {
                hdc = HandPointBuffer[i] as HandPointContact;

                if (hdc.Id == e.ID)
                {
                    break;
                }
            }
            pt.is_non_steady = false;
            pt.SetColor(Brushes.Yellow);
            int     status = 0;
            Point3D hpoint = hdc.RowPoint;

            hpoint.Y = -hpoint.Y;
            Point3D pt3 = depthGen.ConvertRealWorldToProjective(hpoint);

            clipHandFromDepthMap(pt3);
            status = openpalm.isDetected(clipping, pt3);
            if (status == 1)
            {
                Console.WriteLine("OpenHand");
            }
            else if (status == 2)
            {
                Console.WriteLine("Close Hand");
            }
            Multitouch.Contracts.ContactState st = hdc.State;
            if (status == 1 && (st == Multitouch.Contracts.ContactState.Moved || st == Multitouch.Contracts.ContactState.New))
            {
                pt.SetColor(Brushes.Green);
                pt.steady_state = 1;
                pt.is_clicked   = false;

                System.Console.WriteLine("Release...");
                hdc.Update(pt.steady_point.X, pt.steady_point.Y, Multitouch.Contracts.ContactState.Removed);
                inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Removed);

                pt.steady_point = pt.Location;
            }
            else if (status == 2 && st == Multitouch.Contracts.ContactState.Removed)
            {
                System.Console.WriteLine("Grab...");
                pt.steady_state = 2;
                pt.is_clicked   = true;
                pt.SetColor(Brushes.Red);
                hdc.Update(pt.steady_point.X, pt.steady_point.Y, Multitouch.Contracts.ContactState.New);
                inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.New);
                pt.steady_point = pt.Location;
            }
            else
            {
                pt.steady_point = pt.Location;
            }
        }