Пример #1
0
 public SerialSkeletonFrame(NuiSkeletonFrame nui)
 {
     this.liTimeStamp      = nui.liTimeStamp;
     this.dwFrameNumber    = nui.dwFrameNumber;
     this.dwFlags          = nui.dwFlags;
     this.vFloorClipPlane  = new SerialVec4(nui.vFloorClipPlane);
     this.vNormalToGravity = new SerialVec4(nui.vNormalToGravity);
     this.SkeletonData     = new SerialSkeletonData[6];
     for (int ii = 0; ii < 6; ii++)
     {
         this.SkeletonData[ii] = new SerialSkeletonData(nui.SkeletonData[ii]);
     }
 }
Пример #2
0
        public NuiSkeletonFrame deserialize()
        {
            NuiSkeletonFrame nui = new NuiSkeletonFrame();

            nui.liTimeStamp      = this.liTimeStamp;
            nui.dwFrameNumber    = this.dwFrameNumber;
            nui.dwFlags          = this.dwFlags;
            nui.vFloorClipPlane  = this.vFloorClipPlane.deserialize();
            nui.vNormalToGravity = this.vNormalToGravity.deserialize();
            nui.SkeletonData     = new NuiSkeletonData[6];
            for (int ii = 0; ii < 6; ii++)
            {
                nui.SkeletonData[ii] = this.SkeletonData[ii].deserialize();
            }
            return(nui);
        }
Пример #3
0
 public static extern int NuiTransformSmooth(ref NuiSkeletonFrame pSkeletonFrame, ref NuiTransformSmoothParameters pSmoothingParams);
Пример #4
0
 public static extern int NuiSkeletonGetNextFrame(uint dwMillisecondsToWait, ref NuiSkeletonFrame pSkeletonFrame);
Пример #5
0
        private int NuiSkeletonGetNextFrame(uint dwMillisecondsToWait, ref NuiSkeletonFrame pSkeletonFrame)
        {
            if (sourceFlags != KinectInterop.FrameSource.TypeAudio)
            {
                // non-audio sources
                uint iFrameLength = (uint)GetSkeletonFrameLength();
                bool bSuccess = GetSkeletonFrameData(ref pSkeletonFrame, ref iFrameLength, true);
                return bSuccess ? 0 : -1;
            }
            else
            {
                // audio only
                int hr = GetNextSkeletonFrame(dwMillisecondsToWait);

                if (hr == 0)
                {
                    uint iFrameLength = (uint)GetSkeletonFrameLength();
                    bool bSuccess = GetSkeletonFrameData(ref pSkeletonFrame, ref iFrameLength, true);

                    return bSuccess ? 0 : -1;
                }

                return hr;
            }
        }
Пример #6
0
        public KinectInterop.SensorData OpenDefaultSensor(KinectInterop.FrameSource dwFlags, float sensorAngle, bool bUseMultiSource)
        {
            sourceFlags = dwFlags;

            NuiInitializeFlags nuiFlags = // NuiInitializeFlags.UsesNone;
                NuiInitializeFlags.UsesSkeleton | NuiInitializeFlags.UsesDepthAndPlayerIndex;

            if ((dwFlags & KinectInterop.FrameSource.TypeBody) != 0)
            {
                nuiFlags |= NuiInitializeFlags.UsesSkeleton;
            }

            if ((dwFlags & KinectInterop.FrameSource.TypeColor) != 0)
            {
                nuiFlags |= NuiInitializeFlags.UsesColor;
            }

            if ((dwFlags & KinectInterop.FrameSource.TypeDepth) != 0)
            {
                nuiFlags |= NuiInitializeFlags.UsesDepthAndPlayerIndex;
            }

            if ((dwFlags & KinectInterop.FrameSource.TypeBodyIndex) != 0)
            {
                nuiFlags |= NuiInitializeFlags.UsesDepthAndPlayerIndex;
            }

            if ((dwFlags & KinectInterop.FrameSource.TypeInfrared) != 0)
            {
                nuiFlags |= (NuiInitializeFlags.UsesColor | (NuiInitializeFlags)0x8000);
            }

            if ((dwFlags & KinectInterop.FrameSource.TypeAudio) != 0)
            {
                nuiFlags |= NuiInitializeFlags.UsesAudio;
            }

            FacetrackingManager[] faceManagers = GameObject.FindObjectsOfType(typeof(FacetrackingManager)) as FacetrackingManager[];
            if (faceManagers != null && faceManagers.Length > 0)
            {
                for (int i = 0; i < faceManagers.Length; i++)
                {
                    if (faceManagers[i].enabled)
                    {
                        //Debug.Log("Found FacetrackingManager => UsesColor");
                        nuiFlags |= NuiInitializeFlags.UsesColor;
                        break;
                    }
                }
            }

            SpeechManager[] speechManagers = GameObject.FindObjectsOfType(typeof(SpeechManager)) as SpeechManager[];
            if (speechManagers != null && speechManagers.Length > 0)
            {
                for (int i = 0; i < speechManagers.Length; i++)
                {
                    if (speechManagers[i].enabled)
                    {
                        //Debug.Log("Found SpeechManager => UsesAudio");
                        nuiFlags |= NuiInitializeFlags.UsesAudio;
                        break;
                    }
                }
            }

            int hr = InitKinectSensor(nuiFlags, true, (int)Constants.ColorImageResolution, (int)Constants.DepthImageResolution, Constants.IsNearMode);

            if (hr == 0)
            {
                // set sensor angle
                SetKinectElevationAngle((int)sensorAngle);

                // initialize Kinect interaction
                hr = InitKinectInteraction();
                if (hr != 0)
                {
                    Debug.LogError(string.Format("Error initializing KinectInteraction: hr=0x{0:X}", hr));
                }

                KinectInterop.SensorData sensorData = new KinectInterop.SensorData();

                sensorData.bodyCount = Constants.NuiSkeletonCount;
                sensorData.jointCount = Constants.JointCount;

                sensorData.depthCameraFOV = 46.6f;
                sensorData.colorCameraFOV = 48.6f;
                sensorData.depthCameraOffset = 0.01f;
                sensorData.faceOverlayOffset = 0.01f;

                NuiImageResolutionToSize(Constants.ColorImageResolution, out sensorData.colorImageWidth, out sensorData.colorImageHeight);
                //			sensorData.colorImageWidth = Constants.ColorImageWidth;
                //			sensorData.colorImageHeight = Constants.ColorImageHeight;

                if ((dwFlags & KinectInterop.FrameSource.TypeColor) != 0)
                {
                    //colorStreamHandle =  GetColorStreamHandle();
                    sensorData.colorImage = new byte[sensorData.colorImageWidth * sensorData.colorImageHeight * 4];
                }

                NuiImageResolutionToSize(Constants.DepthImageResolution, out sensorData.depthImageWidth, out sensorData.depthImageHeight);
                //			sensorData.depthImageWidth = Constants.DepthImageWidth;
                //			sensorData.depthImageHeight = Constants.DepthImageHeight;

                if ((dwFlags & KinectInterop.FrameSource.TypeDepth) != 0)
                {
                    //depthStreamHandle = GetDepthStreamHandle();
                    sensorData.depthImage = new ushort[sensorData.depthImageWidth * sensorData.depthImageHeight];
                }

                if ((dwFlags & KinectInterop.FrameSource.TypeBodyIndex) != 0)
                {
                    sensorData.bodyIndexImage = new byte[sensorData.depthImageWidth * sensorData.depthImageHeight];
                }

                if ((dwFlags & KinectInterop.FrameSource.TypeInfrared) != 0)
                {
                    sensorData.infraredImage = new ushort[sensorData.colorImageWidth * sensorData.colorImageHeight];
                }

                if ((dwFlags & KinectInterop.FrameSource.TypeBody) != 0)
                {
                    skeletonFrame = new NuiSkeletonFrame()
                    {
                        SkeletonData = new NuiSkeletonData[Constants.NuiSkeletonCount]
                    };

                    // default values used to pass to smoothing function
                    smoothParameters = new NuiTransformSmoothParameters();

                    smoothParameters.fSmoothing = 0.5f;
                    smoothParameters.fCorrection = 0.5f;
                    smoothParameters.fPrediction = 0.5f;
                    smoothParameters.fJitterRadius = 0.05f;
                    smoothParameters.fMaxDeviationRadius = 0.04f;
                }

                return sensorData;
            }
            else
            {
                Debug.LogError("InitKinectSensor failed: " + GetNuiErrorString(hr));
            }

            return null;
        }
Пример #7
0
 private static extern int NuiTransformSmooth(ref NuiSkeletonFrame pSkeletonFrame, ref NuiTransformSmoothParameters pSmoothingParams);
Пример #8
0
 private static extern bool GetSkeletonFrameData(ref NuiSkeletonFrame pSkeletonData, ref uint iDataBufLen, bool bNewFrame);
Пример #9
0
 public static extern int NuiSkeletonGetNextFrame(uint dwMillisecondsToWait, ref NuiSkeletonFrame pSkeletonFrame);
Пример #10
0
 public NuiSkeletonFrame deserialize()
 {
     NuiSkeletonFrame nui = new NuiSkeletonFrame();
     nui.liTimeStamp = this.liTimeStamp;
     nui.dwFrameNumber = this.dwFrameNumber;
     nui.dwFlags = this.dwFlags;
     nui.vFloorClipPlane = this.vFloorClipPlane.deserialize();
     nui.vNormalToGravity = this.vNormalToGravity.deserialize();
     nui.SkeletonData = new NuiSkeletonData[6];
     for(int ii = 0; ii < 6; ii++){
         nui.SkeletonData[ii] = this.SkeletonData[ii].deserialize();
     }
     return nui;
 }
Пример #11
0
 public SerialSkeletonFrame(NuiSkeletonFrame nui)
 {
     this.liTimeStamp = nui.liTimeStamp;
     this.dwFrameNumber = nui.dwFrameNumber;
     this.dwFlags = nui.dwFlags;
     this.vFloorClipPlane = new SerialVec4(nui.vFloorClipPlane);
     this.vNormalToGravity = new SerialVec4(nui.vNormalToGravity);
     this.SkeletonData = new SerialSkeletonData[6];
     for(int ii = 0; ii < 6; ii++){
         this.SkeletonData[ii] = new SerialSkeletonData(nui.SkeletonData[ii]);
     }
 }