Exemplo n.º 1
0
    private void MyDataFrameReady(object sender, Xtr3D.Net.ExtremeMotion.Data.DataFrameReadyEventArgs e)
    {
        using (var dataFrame = e.OpenFrame() as DataFrame)
        {
            if (dataFrame != null)
            {
                currFrameID = dataFrame.FrameKey.FrameNumberKey;
                Debug.Log("Skeleton frame: " + currFrameID + ", state: " + dataFrame.Skeletons[0].TrackingState + ", proximity: " + dataFrame.Skeletons[0].Proximity.SkeletonProximity);
                if (currFrameID <= lastFrameID && currFrameID != 1)                //currFrameId=1 on reset/resume!!!
                {
                    return;
                }

                lastFrameID = currFrameID;

                //update frameRateCalc, we need to call this every frame as we are calculating avarage fps in the last x frames.
                frameRateCalc.UpdateAvgFps();
                JointCollection skl = dataFrame.Skeletons[0].Joints;

                //use a copy of the Joints data structure as the dataFrame values can change.
                typesToJoints[JointType.ShoulderCenter] = skl.ShoulderCenter;
                typesToJoints[JointType.Spine]          = skl.Spine;
                typesToJoints[JointType.HipCenter]      = skl.HipCenter;
                typesToJoints[JointType.ShoulderLeft]   = skl.ShoulderLeft;
                typesToJoints[JointType.ShoulderRight]  = skl.ShoulderRight;
                typesToJoints[JointType.ElbowLeft]      = skl.ElbowLeft;
                typesToJoints[JointType.ElbowRight]     = skl.ElbowRight;
                typesToJoints[JointType.HandRight]      = skl.HandRight;
                typesToJoints[JointType.HandLeft]       = skl.HandLeft;
                typesToJoints[JointType.Head]           = skl.Head;
            }
        }
    }
    private void MyColorImageFrameReadyEventHandler(object sender, ColorImageFrameReadyEventArgs e)
    {
        using (ColorImageFrame colorImageFrame = e.OpenFrame() as ColorImageFrame)
        {
            if (colorImageFrame != null)
            {
                //update frameRateCalc, we need to call this every frame as we are calculating avarage fps in the last x frames.
                frameRateCalc.UpdateAvgFps();

                ColorImage colorImage = colorImageFrame.ColorImage;

                colorImage.Image.CopyTo(newRgbImage, 0);
                newFrameId = colorImageFrame.FrameKey.FrameNumberKey;
                Debug.Log("Raw image frame: " + newFrameId);
            }
        }
    }