private void CalculateGestureDuration() { if (parameters.SkeletonRenderFrames.Count > 0) { int interval = DateTimeUtilities.DifferenceInMilliseconds(gestureStartDateTime, gestureEndDateTime); gestureDuration = TimeSpan.FromMilliseconds(interval); } }
private void UpdateTiming(DateTime timeStamp) { currentExecutionTime = currentExecutionDateTime == DateTime.MinValue ? TimeSpan.Zero : TimeSpan.FromMilliseconds(DateTimeUtilities.DifferenceInMilliseconds(currentExecutionDateTime, timeStamp)); if (currentExecutionTime > maximumGestureDuration) { ResetExecutionParameters(); } currentExecutionDateTime = timeStamp; }
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); }
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); } }
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); }
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); } }
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); }