Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: sbst/code
        pxcmStatus OnModuleProcessedFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            // check if the callback is from the hand tracking module.
            if (mid == PXCMHandModule.CUID)
            {
                PXCMHandModule hand = module.QueryInstance<PXCMHandModule>();
                PXCMHandData handData = hand.CreateOutput();
                handData.Update();
                if (handData == null)
                {
                    Console.WriteLine("Failed Create Output");
                    Console.WriteLine("That`s all...");
                    Console.ReadKey();
                    return 0;
                }
                PXCMHandData.JointData[][] nodes = new PXCMHandData.JointData[][] { new PXCMHandData.JointData[0x20], new PXCMHandData.JointData[0x20] };
                int numOfHands = handData.QueryNumberOfHands();
                for (int i = 0; i < numOfHands; i++)
                {
                    //Get hand by time of appearence
                    PXCMHandData.IHand IhandData;
                    if (handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, i, out IhandData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        if (handData != null)
                        {
                            //Iterate Joints
                            for (int j = 0; j < 0x20; j++)
                            {
                                PXCMHandData.JointData jointData;
                                IhandData.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData);
                                nodes[i][j] = jointData;
                            } // end iterating over joints
                        }
                    }
                } // end itrating over hands
                int numOfGestures = handData.QueryFiredGesturesNumber();
                if (numOfGestures > 0)
                {
                    for (int i = 0; i < numOfGestures; i++)
                    {
                        PXCMHandData.GestureData gestureData;
                        if (handData.QueryFiredGestureData(i, out gestureData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            switch (gestureData.name)
                            {
                                case "thumb_up":
                                    if (vol[3] > 10F)
                                        break;
                                    vol[3] += 0.4F;
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Thumb up" + "\n");
                                    Send("/vol4", vol[3]);
                                    break;

                                case "thumb_down":
                                    vol[3] -= 0.4F;
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Thumb down" + "\n");
                                    Send("/vol4", vol[3]);
                                    break;

                                case "fist":
                                    if (vol[0] < 1.6F)
                                        vol[0] += 0.1F;
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Fist" + "\n");
                                    Send("/vol1", vol[0]);
                                    break;

                                case "spreadfingers":
                                    if (vol[0] > 0.4F)
                                        vol[0] -= 0.1F;
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Spreadfingers" + "\n");
                                //    Send("/vol1", vol[0]);
                                    break;

                                case "full_pinch":
                                    if (vol[4] > 0.9F)
                                        flag3 = 1;

                                    if (vol[4] < 0.1F)
                                        flag3 = 0;

                                    if (flag3 == 0)
                                        vol[4] += 0.1F;
                                    else
                                        vol[4] -= 0.1F;
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Full pinch" + "\n");
                                    Send("/vol2", vol[4]);
                                    break;

                                case "v_sign":
                                    vol[0] = 1F;
                                    Send("/vol1", vol[0]);
                                    vol[4] = 1F;
                                    Send("/vol2", vol[4]);
                                    //vol[2] = 0F;
                                    //Send("/vol3", vol[2]);
                                    vol[3] = 2F;
                                    Send("/vol4", vol[3]);
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) =>  logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: V sign" + "\n");
                                    //vol[4] = 0.5F;
                                    //Send("/vol5", vol[4]);
                                    //vol[5] = 0F;
                                    //Send("/vol6", vol[5]);
                                    break;
                            }
                            Thread.Sleep(500);//100
                        }

                    }
                }

            }
            // return NO_ERROR to continue, or any error to abort.
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Exemplo n.º 2
0
        //  System.Windows.Forms.Timer _timer;
        pxcmStatus OnModuleProcessedFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            thread.Wait();
            if (mid == PXCMHandModule.CUID)
            {
                PXCMHandModule hand = module.QueryInstance<PXCMHandModule>();
                PXCMHandData handData = hand.CreateOutput();
                handData.Update();
                if (handData == null)
                {
                    Console.WriteLine("Failed Create Output");
                    Console.WriteLine("That`s all...");
                    Console.ReadKey();
                    return 0;
                }
                PXCMHandData.JointData[][] nodes = new PXCMHandData.JointData[][] { new PXCMHandData.JointData[0x20], new PXCMHandData.JointData[0x20] };
                int numOfHands = handData.QueryNumberOfHands();
                for (int i = 0; i < numOfHands; i++)
                {
                    //Get hand by time of appearence
                    PXCMHandData.IHand IhandData;
                    if (handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, i, out IhandData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        if (handData != null)
                        {
                            //Iterate Joints
                            for (int j = 0; j < 0x20; j++)
                            {
                                PXCMHandData.JointData jointData;
                                IhandData.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData);
                                nodes[i][j] = jointData;
                            } // end iterating over joints
                        }
                    }
                } // end itrating over hands
                int numOfGestures = handData.QueryFiredGesturesNumber();
                if (numOfGestures > 0)
                {
                    for (int i = 0; i < numOfGestures; i++)
                    {
                        PXCMHandData.GestureData gestureData;
                        if (handData.QueryFiredGestureData(i, out gestureData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            switch (gestureData.name)
                            {
                                case "wave":
                                    string[] response = GET("http://168.63.82.20/api/login", "login=sbst&password=ebc1628c26f8515f81a5178a5abfcbd9").Split('\"');
                                    response = GET("http://168.63.82.20/api/thing", @"user_id=" + response[7] + @"&token=" + response[3] + @"&did=yk5ynj69aw7z").Split('\"'); ;
                                    label1.Invoke(new Inform((s) => label1.Text = s), response[15] + " C");
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text + WindState.ToString()), "GETDATA Temperature:" + response[15] + " C" + "\n");
                                    break;

                                case "tap":
                                    flagLight++;
                                    if (flagLight == 2)
                                    {
                                        if (LightState == 0)
                                            LightState = 1;
                                        else
                                            LightState = 0;
                                        flagLight = 0;
                                        logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), "MAKEDATA LightState:" + LightState + " WindState:" + WindState + "\n");
                                    }

                                    break;

                                case "swipe_up":
                                    flagWind++;
                                    if (flagWind == 2)
                                    {
                                        if (WindState == 0)
                                            WindState = 1;
                                        else
                                            WindState = 0;
                                        flagWind = 0;
                                        logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text + WindState.ToString()), "MAKEDATA LightState:" + LightState + " WindState:" + WindState + "\n");
                                    }
                                    break;

                                case "thumb_up":
                                    SendState++;
                                    if (SendState == 2)
                                    {
                                        if (LightState == 0)
                                            ChangeSwitch(DidLight, "501");
                                        else
                                            ChangeSwitch(DidLight, "498");

                                        if (WindState == 0)
                                            ChangeSwitch(DidWind, "501");
                                        else
                                            ChangeSwitch(DidWind, "498");
                                        logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), "SENDDATA LightState:" + LightState + " WindState:" + WindState + "\n");
                                        //SendState = 0;
                                    }
                                    break;
                                    //textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    //textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    //textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    //logTextBox.Invoke(new Inform((s) =>  logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: V sign" + "\n");
                            }
                        }

                    }
                }
            }
            //Thread.Sleep(100);
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Exemplo n.º 3
0
Arquivo: source.cs Projeto: sbst/code
        pxcmStatus OnModuleProcessedFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            thread.Wait();
            if (mid == PXCMHandModule.CUID)
            {
                PXCMHandModule hand = module.QueryInstance<PXCMHandModule>();
                PXCMHandData handData = hand.CreateOutput();
                handData.Update();
                if (handData == null)
                {
                    Console.WriteLine("Failed Create Output");
                    Console.WriteLine("That`s all...");
                    Console.ReadKey();
                    return 0;
                }
                PXCMHandData.JointData[][] nodes = new PXCMHandData.JointData[][] { new PXCMHandData.JointData[0x20], new PXCMHandData.JointData[0x20] };
                int numOfHands = handData.QueryNumberOfHands();
                for (int i = 0; i < numOfHands; i++)
                {
                    //Get hand by time of appearence
                    PXCMHandData.IHand IhandData;
                    if (handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, i, out IhandData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        if (handData != null)
                        {
                            //Iterate Joints
                            for (int j = 0; j < 0x20; j++)
                            {
                                PXCMHandData.JointData jointData;
                                IhandData.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData);
                                nodes[i][j] = jointData;
                            } // end iterating over joints
                        }
                    }
                } // end itrating over hands
                int numOfGestures = handData.QueryFiredGesturesNumber();
                if (numOfGestures > 0)
                {
                    for (int i = 0; i < numOfGestures; i++)
                    {
                        PXCMHandData.GestureData gestureData;
                        if (handData.QueryFiredGestureData(i, out gestureData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            switch (gestureData.name)
                            {
                                case "thumb_up":
                                    break;

                                case "thumb_down":
                                    break;

                                case "fist":
                                    break;

                                case "spreadfingers":
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Spreadfingers" + "\n");
                                    break;

                                case "full_pinch":
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Full pinch" + "\n");
                                    break;

                                case "v_sign":
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) =>  logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: V sign" + "\n");
                                    break;
                            }
                        }

                    }
                }

            }
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }