Esempio n. 1
0
        //protected bool IsSognut(PXCMHandData.JointData[] nodes, PXCMHandData.JointType center, PXCMHandData.JointType mid, PXCMHandData.JointType tip)
        protected bool IsSognut(PXCMHandData.JointData[] nodes, PXCMHandData.JointType center, int mid, int tip)
        {
            float distanceTip = Distance(nodes[(int)center].positionWorld, nodes[(int)tip].positionWorld);
            float distanceMid = Distance(nodes[(int)center].positionWorld, nodes[(int)mid].positionWorld);

            return(distanceMid > distanceTip);
        }
 private void SetJointdata(PXCMHandData.IHand handInfo, PXCMHandData.JointType jointType, Item joint)
 {
     PXCMHandData.JointData jointData;
     if (handInfo.QueryTrackedJoint(jointType, out jointData) != NoError)
     {
         joint.IsVisible = false;
         return;
     }
     SetVisibleJointPosition(joint, jointData);
 }
Esempio n. 3
0
        private static Point GetPointFromJoint(PXCMHandData.IHand currentHandData, PXCMHandData.JointType jointType)
        {
            PXCMHandData.JointData jointData;
            currentHandData.QueryTrackedJoint(jointType, out jointData);
            var positionImage = jointData.positionImage;
            int x             = (int)(WIDTH - positionImage.x);
            int y             = (int)positionImage.y;

            return(new Point
            {
                X = x,
                Y = y
            });
        }
Esempio n. 4
0
        void DrawJoint(int handId, PXCMHandData.JointType joint)
        {
            var           position = this.handMap[handId][joint];
            ModelVisual3D visual;

            if (!this.drawnHandJointVisualMap[handId].TryGetValue(joint, out visual))
            {
                visual =
                    MakeSphereForHandPosition(handId, position.x, position.y, position.z);

                this.drawnHandJointVisualMap[handId][joint] = visual;

                this.modelVisual.Children.Add(visual);
            }
            var transform = ((TranslateTransform3D)visual.Transform);

            transform.OffsetX = position.x;
            transform.OffsetY = position.y;
            transform.OffsetZ = position.z;
        }
Esempio n. 5
0
        /// <summary> 指のデータを取得する </summary>
        private void GetFingerData(PXCMHandData.IHand hand, PXCMHandData.JointType jointType)
        {
            PXCMHandData.JointData jointData;
            var sts = hand.QueryTrackedJoint(jointType, out jointData);

            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                return;
            }

            // Depth座標系をカラー座標系に変換する
            var depthPoint = new PXCMPoint3DF32[1];
            var colorPoint = new PXCMPointF32[1];

            depthPoint[0].x = jointData.positionImage.x;
            depthPoint[0].y = jointData.positionImage.y;
            depthPoint[0].z = jointData.positionWorld.z * 1000;
            projection.MapDepthToColor(depthPoint, colorPoint);

            var masp = hand.QueryMassCenterImage();
            var mdp  = new PXCMPoint3DF32[1];
            var mcp  = new PXCMPointF32[1];

            mdp[0].x = masp.x;
            mdp[0].y = masp.y;
            mdp[0].z = hand.QueryMassCenterWorld().z * 1000;

            projection.MapDepthToColor(mdp, mcp);
            //Console.WriteLine(mcp[0].x);
            AddEllipse(new Point(mcp[0].x, mcp[0].y), 10, Brushes.Red, 1);
            colorPoint = mcp;

            //AddEllipse(new Point(colorPoint[0].x, colorPoint[0].y), 5, Brushes.White, 1);

            if (ensembleTimer.IsEnabled)
            {
                DetectTap(hand, mcp[0]);
            }
            //if (ensembleTimer.IsEnabled) RecogMove(hand,mcp[0]);
            //RecogMove(hand,mcp[0]);
        }
 internal extern static IntPtr PXCMPointConverterFactory_CreateHandJointConverter(IntPtr instance, IntPtr handData, PXCMHandData.AccessOrderType accessOrder, Int32 index, PXCMHandData.JointType jointType);
Esempio n. 7
0
    /** @brief Create hand joint data PointConverter for PXCMHandModule
     *          The converter will convert joint position to target rectangle/3dbox based on requested hand.
     *          @note Make sure the handData is constantly updated throughtout the session.
     *          @example pointConverter.CreateHandJointConverter(handData,PXCMHandData.ACCESS_ORDER_BY_TIME,0,PXCMHandData.JOINT_WRIST);
     *          @param[in] handData a pointer to PXCHandData
     *          @param[in] accessOrder The desired hand access order
     *          @param[in] index hand index
     *          @param[in] jointType desired joint type to be converted
     *          @return an object of the created PointConverter, or null in case of illegal arguments
     */
    public PXCMPointConverter CreateHandJointConverter(PXCMHandData handData, PXCMHandData.AccessOrderType accessOrder, Int32 index, PXCMHandData.JointType jointType)
    {
        IntPtr inst2 = PXCMPointConverterFactory_CreateHandJointConverter(instance, handData.instance, accessOrder, index, jointType);

        return((inst2 == IntPtr.Zero) ? null : new PXCMPointConverter(inst2, true));
    }
Esempio n. 8
0
 /**
  *  @brief Disable calculation of the speed of a specific joint.\n
  *  You may want to disable the feature when it is no longer needed, in order to conserve CPU and memory resources.\n
  *  @param[in] jointLabel - the identifier of the joint
  *
  *  @return PXCM_STATUS_NO_ERROR - operation succeeded.
  *  @return PXCM_STATUS_PARAM_UNSUPPORTED - invalid joint label.
  *
  *  @see PXCMHandData.JointType
  */
 public pxcmStatus DisableJointSpeed(PXCMHandData.JointType jointLabel)
 {
     return(PXCMHandConfiguration_DisableJointSpeed(instance, jointLabel));
 }
Esempio n. 9
0
 /**
  *   @brief Activate calculation of the speed of a specific joint, according to the given mode.\n
  *
  *   The output speed is a 3-dimensional vector, containing the the motion of the requested joint in each direction (x, y and z axis).\n
  *   By default, the joint speed calculation is disabled for all joints, in order to conserve CPU and memory resources.\n
  *   Typically the feature is only activated for a single fingertip or palm-center joint, as only the overall hand speed is useful.\n
  *
  *   @param[in] jointLabel - the identifier of the joint.
  *   @param[in] jointSpeed - the speed calculation method. Possible values are:\n
  *     JOINT_SPEED_AVERAGE  - calculate the average joint speed, over the time period defined in the "time" parameter.\n
  *     JOINT_SPEED_ABSOLUTE - calculate the average of the absolute-value joint speed, over the time period defined in the "time" parameter.\n
  *   @param[in] time - the period in milliseconds over which the average speed will be calculated (a value of 0 will return the current speed).
  *
  *   @return PXCM_STATUS_NO_ERROR - operation succeeded.
  *   @return PXCM_STATUS_PARAM_UNSUPPORTED - one of the arguments is invalid.
  *
  *   @see PXCMHandData.JointType
  *   @see PXCMHandData.JointSpeedType
  */
 public pxcmStatus EnableJointSpeed(PXCMHandData.JointType jointLabel, PXCMHandData.JointSpeedType jointSpeed, Int32 time)
 {
     return(PXCMHandConfiguration_EnableJointSpeed(instance, jointLabel, jointSpeed, time));
 }
Esempio n. 10
0
 internal static extern pxcmStatus PXCMHandConfiguration_DisableJointSpeed(IntPtr instance, PXCMHandData.JointType jointLabel);
Esempio n. 11
0
 internal static extern pxcmStatus PXCMHandConfiguration_EnableJointSpeed(IntPtr instance, PXCMHandData.JointType jointLabel, PXCMHandData.JointSpeedType jointSpeed, Int32 time);
Esempio n. 12
0
    /* Constructor */
    public HandsData(int MaxHands, int MaxJoints)
    {
        NumOfHands  = MaxHands;
        NumOfJoints = MaxJoints;
        JointData   = new PXCMHandData.JointData[NumOfHands][]; // Joint coordinates
        Coordinates = new Main.HandCoord[NumOfHands];

        /* Declaration of the array for the hand data*/
        for (int i = 0; i < NumOfHands; i++)
        {
            JointData[i]   = new PXCMHandData.JointData[NumOfJoints];
            Coordinates[i] = new Main.HandCoord(6, NumOfJoints);
            for (int j = 0; j < NumOfJoints; j++)
            {
                JointData[i][j] = new PXCMHandData.JointData();
            }
        }

        /* Initialization of SenseManager */
        SenseManager = PXCMSenseManager.CreateInstance();
        if (SenseManager == null)
        {
            Debug.LogError("Initialization of the SenseManager has failed");
        }

        /* Enable hand tracking and get an instance of an hand module */
        Status     = SenseManager.EnableHand();
        HandModule = SenseManager.QueryHand();
        if (Status != pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            Debug.LogError("SenseManager --> EnableHand " + Status);
        }

        /* Create the connection to the Intel RealSense camera */
        Status = SenseManager.Init();
        if (Status != pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            Debug.LogError("Initialization of SenseManager: " + Status);
        }



        /* Settings for the hand module */
        PXCMHandConfiguration HandConfig = HandModule.CreateActiveConfiguration();

        if (HandConfig != null)
        {
            HandConfig.EnableAllGestures();
            HandConfig.EnableAlert(PXCMHandData.AlertType.ALERT_HAND_NOT_DETECTED);

            PXCMHandData.JointType st = PXCMHandData.JointType.JOINT_WRIST;
            for (int i = 0; i < NumOfJoints; i++)
            {
                HandConfig.EnableJointSpeed(st, PXCMHandData.JointSpeedType.JOINT_SPEED_AVERAGE, 1000 / 10);
                st++;
            }

            //HandConfig.EnableJointSpeed(PXCMHandData.JointType.JOINT_WRIST, PXCMHandData.JointSpeedType.JOINT_SPEED_ABSOLUTE,1000/20);
            HandConfig.ApplyChanges();
            HandConfig.Dispose();
        }
    }
Esempio n. 13
0
        /// <summary> 指のデータを取得する </summary>
        private bool GetFingerData(PXCMHandData.IHand hand, PXCMHandData.JointType jointType)
        {
            PXCMHandData.JointData jointData;
            var sts = hand.QueryTrackedJoint(jointType, out jointData);

            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                return(false);
            }
            // Depth座標系をカラー座標系に変換する
            var depthPoint = new PXCMPoint3DF32[1];
            var colorPoint = new PXCMPointF32[1];

            depthPoint[0].x = jointData.positionImage.x;
            depthPoint[0].y = jointData.positionImage.y;
            depthPoint[0].z = jointData.positionWorld.z * 1000;
            projection.MapDepthToColor(depthPoint, colorPoint);

            var masp = hand.QueryMassCenterImage();
            var mdp  = new PXCMPoint3DF32[1];
            var mcp  = new PXCMPointF32[1];

            mdp[0].x = masp.x;
            mdp[0].y = masp.y;
            mdp[0].z = hand.QueryMassCenterWorld().z * 1000;
            projection.MapDepthToColor(mdp, mcp);
            //Console.WriteLine(mcp[0].x);
            AddEllipse(new Point(mcp[0].x, mcp[0].y), 10, Brushes.Red, 1);
            colorPoint = mcp;

            //ユーザの右手に対して演奏領域の当たり判定確認
            if (hand.QueryBodySide() == PXCMHandData.BodySideType.BODY_SIDE_LEFT)
            {
                for (int i = 0; i < 5; i++)
                {
                    if ((imageColor.Height / 5) * i <= colorPoint[0].y && colorPoint[0].y < (imageColor.Height / 5) * (i + 1))
                    {
                        if (16 - i != NowRange)
                        {
                            NowRange = 16 - i;
                            PivotList.Dispatcher.BeginInvoke(
                                new Action(() =>
                            {
                                PivotList.SelectedItem = NowRange;
                            }
                                           ));
                        }
                    }
                }
            }

            //ユーザの左手に対してアイコンの当たり判定の確認
            if (hand.QueryBodySide() == PXCMHandData.BodySideType.BODY_SIDE_RIGHT)
            {
                IconHitCheck(colorPoint[0]);
            }

            AddEllipse(new Point(colorPoint[0].x, colorPoint[0].y), 5, Brushes.White, 1);

            return(true);
        }