示例#1
0
        static void Main()
        {
            b = new Bitmap(640, 480, PixelFormat.Format32bppArgb);

            hand  = new JointTracker();
            elbow = new JointTracker();
            myK   = KinectSensor.KinectSensors[0];
            myK.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            myK.SkeletonStream.Enable();
            myK.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);

            myK.Start();

            myK.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
            myK.ColorFrameReady    += new EventHandler <ColorImageFrameReadyEventArgs>(ColorImageFrameReady);
            myK.DepthFrameReady    += new EventHandler <DepthImageFrameReadyEventArgs>(DepthFrameReady);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            f = new cameraForm();

            beginListening();
            f.setConnectionL("Listening on port " + PORT);

            Application.Run(f);
        }
示例#2
0
        public static void processArm(JointTracker hand, JointTracker elbow, out SkeletonPoint output)
        {
            output = JointTracker.zeroVec();
            double s = JointTracker.slope(JointTracker.vecSubt(hand.position(), elbow.position()));

            if (s > -.4 && s < .19)
            {
                JointTracker.vecAdd(ref output, hand.lastDistance());
            }
            //Console.WriteLine(s);
        }
示例#3
0
        public static void sendData()
        {
            if (clientS != null)
            {
                double s    = JointTracker.slope(JointTracker.vecSubt(hand.position(), elbow.position()));
                bool   grab = false;
                if (s > -1.5 && s < .19)
                {
                    grab = true;
                }

                int handX, handZ;

                handX = (int)(hand.lastDistance().X *1000000);
                handZ = (int)(hand.lastDistance().Z *1000000);
                //Console.WriteLine(handX);
                byte[] temp = new byte[9];
                temp[0] = 0;
                if (grab)
                {
                    temp[0] = 0x80;
                }
                temp[1] = (byte)(handX);
                temp[2] = (byte)(handX >> 8);
                temp[3] = (byte)(handX >> 16);
                temp[4] = (byte)(handX >> 24);
                temp[5] = (byte)(handZ);
                temp[6] = (byte)(handZ >> 8);
                temp[7] = (byte)(handZ >> 16);
                temp[8] = (byte)(handZ >> 24);
                //Console.WriteLine(getBits(temp[4])+getBits(temp[3])+getBits(temp[2])+getBits(temp[1])+handX);
                if (socketOpen)
                {
                    try
                    {
                        clientS.Send(temp);
                    }
                    catch (SocketException)
                    {
                        f.setConnectionL("Connection lost, listening on port " + PORT);
                        socketOpen = false;
                        //listenS.Bind(new IPEndPoint(IPAddress.Any, 20736));
                        listenS.Listen(4);
                        listenS.BeginAccept(new AsyncCallback(OnCallAccept), null);
                    }
                }
            }
        }
示例#4
0
        static void Main()
        {
            b = new Bitmap(640, 480, PixelFormat.Format32bppArgb);

            hand = new JointTracker();
            elbow = new JointTracker();
            myK = KinectSensor.KinectSensors[0];
            myK.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            myK.SkeletonStream.Enable();
            myK.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);

            myK.Start();

            myK.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
            myK.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(ColorImageFrameReady);
            myK.DepthFrameReady += new EventHandler<DepthImageFrameReadyEventArgs>(DepthFrameReady);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            f = new cameraForm();

            beginListening();
            f.setConnectionL("Listening on port " + PORT);

            Application.Run(f);
        }
示例#5
0
        public static void processArm(JointTracker hand, JointTracker elbow, out SkeletonPoint output)
        {
            output = JointTracker.zeroVec();
            double s = JointTracker.slope(JointTracker.vecSubt(hand.position(),elbow.position()));

            if(s>-.4 && s<.19)
            {
                JointTracker.vecAdd(ref output, hand.lastDistance());
            }
            //Console.WriteLine(s);
        }