Пример #1
0
 private static extern HRESULT NuiSkeletonGetNextFrame(uint dwMillisecondsToWait, ref NuiSkeletonFrame pSkeletonFrame);
Пример #2
0
 private static extern HRESULT NuiTransformSmooth(ref NuiSkeletonFrame pSkeletonFrame, ref TransformSmoothParameters pSmoothingParams);
Пример #3
0
        internal SkeletonFrame OpenNextFrame()
        {
            var frame = new NuiSkeletonFrame();

            // Get the next NuiSkeletonFrame.
            var res = NuiSkeletonGetNextFrame(0, ref frame);

            if (res == HRESULT.S_FALSE) return null;
            if (res != HRESULT.S_OK) throw new KinectException("Failed to get next frame");

            // Apply TransformSmoothing.
            if (TransformSmooth)
                res = NuiTransformSmooth(ref frame, ref smoothParameters);

            if (res == HRESULT.S_FALSE) return null;
            if (res != HRESULT.S_OK) throw new KinectException("Failed to get next frame");

            // Read every native SkeletonData object into a Skeleton object.
            for (int index = 0; index < frame.skeletonData.Length; index++) {

                var nuiData = frame.skeletonData[index];

                if (nuiData.eTrackingState == SkeletonTrackingState.Tracked) {

                    var joints = new List<Joint>();

                    for (int i = 0; i < nuiData.skeletonPositions.Length; i++)
                        joints.Add(new Joint((JointType)i, nuiData.skeletonPositions[i], nuiData.eSkeletonPositionTrackingState[i]));

                    var collection = new JointCollection(joints);

                    skeletonData[index] = new Skeleton(nuiData.eTrackingState, (int)nuiData.dwTrackingID, (int)nuiData.dwEnrollmentIndex, nuiData.position, collection);

                } else skeletonData[index] = new Skeleton();
            }

            return new SkeletonFrame(frame.liTimeStamp, (int)frame.dwFrameNumber, frame.vFloorClipPlane, skeletonData);
        }