Ejemplo n.º 1
0
        public static FubiUtils.RecognitionResult getCombinationRecognitionProgressOn(string recognizerName, UInt32 userID, out FubiTrackingData[] userStates, bool restart = true)
        {
            IntPtr vec     = FubiInternal.createTrackingDataVector();
            IntPtr namePtr = Marshal.StringToHGlobalAnsi(recognizerName);

            FubiUtils.RecognitionResult recognized = FubiInternal.getCombinationRecognitionProgressOn(namePtr, userID, vec, restart);
            Marshal.FreeHGlobal(namePtr);
            if (recognized == FubiUtils.RecognitionResult.RECOGNIZED)
            {
                UInt32 size = FubiInternal.getTrackingDataVectorSize(vec);
                userStates = new FubiTrackingData[size];
                for (UInt32 i = 0; i < size; i++)
                {
                    IntPtr           tInfo = FubiInternal.getTrackingData(vec, i);
                    FubiTrackingData info  = new FubiTrackingData();
                    for (UInt32 j = 0; j < (uint)FubiUtils.SkeletonJoint.NUM_JOINTS; ++j)
                    {
                        FubiInternal.getSkeletonJointPosition(tInfo, (FubiUtils.SkeletonJoint)j, out info.jointPositions[j].x, out info.jointPositions[j].y, out info.jointPositions[j].z, out info.jointPositions[j].confidence, out info.timeStamp);
                        double timeStamp = 0;
                        FubiInternal.getSkeletonJointOrientation(tInfo, (FubiUtils.SkeletonJoint)j, info.jointOrientations[j].rotMat, out info.jointPositions[j].confidence, out timeStamp);
                        info.timeStamp = Math.Max(timeStamp, info.timeStamp);
                    }
                    userStates[i] = info;
                }
            }
            else
            {
                userStates = null;
            }

            FubiInternal.releaseTrackingDataVector(vec);
            return(recognized);
        }
Ejemplo n.º 2
0
Archivo: Fubi.cs Proyecto: user-mfp/IMI
        public static void updateTrackingData(uint userId, FubiTrackingData data, FubiAccelerationData accelData = null)
        {
            GCHandle hSkeleton = new GCHandle();
            GCHandle hAccel = new GCHandle();
            IntPtr skelPointer = new IntPtr(0);
            IntPtr accelPointer = new IntPtr(0);
            double timeStamp = -1;

            if (data != null)
            {
                float[] skeletonArray = data.getArray();
                hSkeleton = GCHandle.Alloc(skeletonArray, GCHandleType.Pinned);
                skelPointer = hSkeleton.AddrOfPinnedObject();
                timeStamp = data.timeStamp;
            }
            if (accelData != null)
            {
                float[] accelArray = accelData.getArray();
                hAccel = GCHandle.Alloc(accelArray, GCHandleType.Pinned);
                accelPointer = hAccel.AddrOfPinnedObject();
                if (timeStamp < 0)
                    timeStamp = accelData.timeStamp;
            }

            FubiInternal.updateTrackingData(userId, skelPointer, timeStamp, accelPointer);

            if (hSkeleton.IsAllocated)
                hSkeleton.Free();
            if (hAccel.IsAllocated)
                hAccel.Free();
        }
Ejemplo n.º 3
0
Archivo: Fubi.cs Proyecto: user-mfp/IMI
        public static FubiUtils.RecognitionResult getCombinationRecognitionProgressOn(string recognizerName, UInt32 userID, out FubiTrackingData[] userStates,
            out FubiUtils.RecognitionCorrectionHint correctionHint, bool restart = true, bool returnFilteredData = false)
        {
            IntPtr vec = FubiInternal.createTrackingDataVector();
            IntPtr namePtr = Marshal.StringToHGlobalAnsi(recognizerName);
            FubiUtils.RecognitionCorrectionHint hint = new FubiUtils.RecognitionCorrectionHint();
            FubiUtils.RecognitionResult recognized = FubiInternal.getCombinationRecognitionProgressOn(namePtr, userID, vec, restart, returnFilteredData, hint);
            correctionHint = hint;
            Marshal.FreeHGlobal(namePtr);
            if (recognized == FubiUtils.RecognitionResult.RECOGNIZED)
            {
                UInt32 size = FubiInternal.getTrackingDataVectorSize(vec);
                userStates = new FubiTrackingData[size];
                for (UInt32 i = 0; i < size; i++)
                {
                    IntPtr tInfo = FubiInternal.getTrackingData(vec, i);
                    FubiTrackingData info = new FubiTrackingData();
                    for (UInt32 j = 0; j < (uint)FubiUtils.SkeletonJoint.NUM_JOINTS; ++j)
                    {
                        FubiInternal.getSkeletonJointPosition(tInfo, (FubiUtils.SkeletonJoint)j, out info.jointPositions[j].x, out info.jointPositions[j].y, out info.jointPositions[j].z, out info.jointPositions[j].confidence, out info.timeStamp);
                        double timeStamp = 0;
                        float[] rotMat = new float[9];
                        FubiInternal.getSkeletonJointOrientation(tInfo, (FubiUtils.SkeletonJoint)j, rotMat, out info.jointPositions[j].confidence, out timeStamp);
                        FubiUtils.Math.rotMatToRotation(rotMat, out info.jointOrientations[j].rx, out info.jointOrientations[j].ry, out info.jointOrientations[j].rz);
                        info.timeStamp = Math.Max(timeStamp, info.timeStamp);
                    }
                    userStates[i] = info;
                }
            }
            else
                userStates = null;

            FubiInternal.releaseTrackingDataVector(vec);
            return recognized;
        }
Ejemplo n.º 4
0
Archivo: Fubi.cs Proyecto: user-mfp/IMI
 public static FubiUtils.RecognitionResult getCombinationRecognitionProgressOn(string recognizerName, UInt32 userID, out FubiTrackingData[] userStates,
    bool restart = true, bool returnFilteredData = false)
 {
     FubiUtils.RecognitionCorrectionHint hint = new FubiUtils.RecognitionCorrectionHint();
     return getCombinationRecognitionProgressOn(recognizerName, userID, out userStates, out hint, restart, returnFilteredData);
 }
Ejemplo n.º 5
0
Archivo: Fubi.cs Proyecto: user-mfp/IMI
 public static FubiUtils.RecognitionResult getCombinationRecognitionProgressOn(FubiPredefinedGestures.Combinations combinationID, UInt32 userID, out FubiTrackingData[] userStates,
     bool restart = true, bool returnFilteredData = false)
 {
     FubiUtils.RecognitionCorrectionHint dummy = new FubiUtils.RecognitionCorrectionHint();
     return getCombinationRecognitionProgressOn(combinationID, userID, out userStates, out dummy, restart, returnFilteredData);
 }
Ejemplo n.º 6
0
 public static FubiUtils.RecognitionResult getCombinationRecognitionProgressOn(FubiPredefinedGestures.Combinations combinationID, UInt32 userID, out FubiTrackingData[] userStates, bool restart = true)
 {
     IntPtr vec = FubiInternal.createTrackingDataVector();
     FubiUtils.RecognitionResult recognized = FubiInternal.getCombinationRecognitionProgressOn(combinationID, userID, vec, restart);
     if (recognized == FubiUtils.RecognitionResult.RECOGNIZED)
     {
         UInt32 size = FubiInternal.getTrackingDataVectorSize(vec);
         userStates = new FubiTrackingData[size];
         for (UInt32 i = 0; i < size; i++)
         {
             IntPtr tInfo = FubiInternal.getTrackingData(vec, i);
             FubiTrackingData info = new FubiTrackingData();
             for (UInt32 j = 0; j < (uint)FubiUtils.SkeletonJoint.NUM_JOINTS; ++j)
             {
                 FubiInternal.getSkeletonJointPosition(tInfo, (FubiUtils.SkeletonJoint)j, out info.jointPositions[j].x, out info.jointPositions[j].y, out info.jointPositions[j].z, out info.jointPositions[j].confidence, out info.timeStamp);
                 double timeStamp = 0;
                 FubiInternal.getSkeletonJointOrientation(tInfo, (FubiUtils.SkeletonJoint)j, info.jointOrientations[j].rotMat, out info.jointPositions[j].confidence, out timeStamp);
                 info.timeStamp = Math.Max(timeStamp, info.timeStamp);
             }
             userStates[i] = info;
         }
         FubiInternal.releaseTrackingDataVector(vec);
     }
     else
         userStates = null;
     return recognized;
 }