예제 #1
0
 private void CalculateGestureDuration()
 {
     if (parameters.SkeletonRenderFrames.Count > 0)
     {
         int interval = DateTimeUtilities.DifferenceInMilliseconds(gestureStartDateTime, gestureEndDateTime);
         gestureDuration = TimeSpan.FromMilliseconds(interval);
     }
 }
예제 #2
0
        private void UpdateTiming(DateTime timeStamp)
        {
            currentExecutionTime = currentExecutionDateTime == DateTime.MinValue ? TimeSpan.Zero :
                                   TimeSpan.FromMilliseconds(DateTimeUtilities.DifferenceInMilliseconds(currentExecutionDateTime, timeStamp));
            if (currentExecutionTime > maximumGestureDuration)
            {
                ResetExecutionParameters();
            }

            currentExecutionDateTime = timeStamp;
        }
예제 #3
0
            private void RenderTimeStampedFrame(DateTime now, DateTime next)
            {
                if (renderFrames[now].Count > 0 && renderFrames[now][0].Image != null)
                {
                    ImageRendered(renderFrames[now][0].Image, now);
                }

                // Assumes the intervals differ by minutes at most.
                int interval = DateTimeUtilities.DifferenceInMilliseconds(now, next);

                Thread.Sleep(interval);
            }
예제 #4
0
        private void UpdateSkeletonFrames(List <SkeletonRenderFrame> capturedFrames, DateTime timeStamp)
        {
            DateTime oldest = skeletonFrames.OldestFrameTime;

            if (oldest != DateTime.MinValue && DateTimeUtilities.DifferenceInMilliseconds(oldest, timeStamp) > renderDuration.TotalSeconds * 1000)
            {
                skeletonFrames.Remove(oldest);
                UpdateSkeletonFrames(capturedFrames, timeStamp);
            }
            else
            {
                skeletonFrames.Add(timeStamp, capturedFrames);
            }
        }
예제 #5
0
        private TimeSpan GetTimeSpanSinceLastCapture(DateTime timeStamp)
        {
            TimeSpan timeSpan;

            if (previousTimeStamp.Equals(DateTime.MinValue))
            {
                timeSpan = TimeSpan.Zero;
            }
            else
            {
                timeSpan = TimeSpan.FromMilliseconds(DateTimeUtilities.DifferenceInMilliseconds(previousTimeStamp, timeStamp));
            }

            return(timeSpan);
        }
예제 #6
0
            private void CalculateTotalFramesCapture()
            {
                // Sample the total frames capture. Build the working frames capture via the framesPerSecondCapture frequency.
                // Create a collection of frames existing in a one second interval (potentially longer). Sample the one
                // second collection and update the working frames capture.

                SkeletonRenderFrames oneSecondIntervalFrames = new SkeletonRenderFrames();

                TimeSpan oneSecond    = TimeSpan.FromSeconds(1);
                TimeSpan intervalSpan = TimeSpan.Zero;
                TimeSpan deltaFrameSpan;

                foreach (DateTime timeStamp in rawFramesCapture.FramesTimeStamps)
                {
                    if (intervalSpan.Equals(TimeSpan.Zero))
                    {
                        oneSecondIntervalFrames = new SkeletonRenderFrames();
                    }
                    if (parameters.SkeletonRenderFrames[timeStamp].Count == 0)
                    {
                        continue;
                    }

                    oneSecondIntervalFrames.Add(timeStamp, rawFramesCapture[timeStamp]);
                    deltaFrameSpan = TimeSpan.FromMilliseconds(DateTimeUtilities.DifferenceInMilliseconds(gestureStartDateTime, timeStamp));
                    intervalSpan   = intervalSpan.Add(deltaFrameSpan);

                    if (intervalSpan >= oneSecond)
                    {
                        UpdateFramesCapture(oneSecondIntervalFrames);
                        intervalSpan = TimeSpan.Zero;
                    }
                }

                // In case the last interval was not caught, capture it.
                if (oneSecondIntervalFrames.Count != 0)
                {
                    UpdateFramesCapture(oneSecondIntervalFrames);
                }
            }
예제 #7
0
            private void BuildFrame(SkeletonRenderFrame frame)
            {
                // Converts the frame into a collection of GestureTrees and adds it to the MovingGestureTree.

                int      milliseconds = DateTimeUtilities.DifferenceInMilliseconds(gestureStartDateTime, frame.TimeStamp);
                TimeSpan frameTime    = TimeSpan.FromMilliseconds(milliseconds);
                TimeSpan minDeltaTime = frameTime < captureTimeTolerance ? TimeSpan.Zero : frameTime.Subtract(captureTimeTolerance);
                TimeSpan maxDeltaTime = frameTime.Add(captureTimeTolerance);

                // RBakerFlag -> Ignore head and spine for now.
                //GestureTree headAndSpineTree = new GestureTree(
                //    SkeletonMiningUtilities.GetJointCollection(frame.Skeleton, SkeletonMiningUtilities.SkeletonJointCollection.HeadAndSpine),
                //    GestureStandardToleranceParameters.JointAngleTolerance, minDeltaTime, maxDeltaTime);
                //movingGestureTree.GestureTrees.Add(headAndSpineTree);

                GestureTree rightArmTree = new GestureTree(
                    SkeletonMiningUtilities.GetJointCollection(frame.Skeleton, SkeletonMiningUtilities.SkeletonJointCollection.RightArm),
                    GestureStandardToleranceParameters.JointAngleTolerance, minDeltaTime, maxDeltaTime);

                movingGestureTree.GestureTrees.Add(rightArmTree);

                GestureTree leftArmTree = new GestureTree(
                    SkeletonMiningUtilities.GetJointCollection(frame.Skeleton, SkeletonMiningUtilities.SkeletonJointCollection.LeftArm),
                    GestureStandardToleranceParameters.JointAngleTolerance, minDeltaTime, maxDeltaTime);

                movingGestureTree.GestureTrees.Add(leftArmTree);

                // RBakerFlag -> Ignore legs for now.
                //GestureTree rightLegTree = new GestureTree(
                //   SkeletonMiningUtilities.GetJointCollection(frame.Skeleton, SkeletonMiningUtilities.SkeletonJointCollection.RightLeg),
                //   GestureStandardToleranceParameters.JointAngleTolerance, minDeltaTime, maxDeltaTime);
                //movingGestureTree.GestureTrees.Add(rightLegTree);

                //GestureTree leftLegTree = new GestureTree(
                //   SkeletonMiningUtilities.GetJointCollection(frame.Skeleton, SkeletonMiningUtilities.SkeletonJointCollection.LeftLeg),
                //   GestureStandardToleranceParameters.JointAngleTolerance, minDeltaTime, maxDeltaTime);
                //movingGestureTree.GestureTrees.Add(leftLegTree);
            }