Skip to content

Commit 2ff03bb

Browse files
committed
fixing a frame incrementing issue
1 parent baa29c0 commit 2ff03bb

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

Ghosts/MainWindow.xaml.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ private void timer_Elapsed(object sender, ElapsedEventArgs e)
283283

284284
private void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
285285
{
286-
frameCount++;
287-
288286
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
289287
{
290288
if (colorFrame != null)
291289
{
290+
frameCount++;
291+
292292
using (DrawingContext dc = this.drawingGroup.Open())
293293
{
294294
// Copy the pixel data from the image to a temporary array
@@ -330,7 +330,7 @@ private void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs
330330
GhostSkeleton skeleton = sequence.SavedSkeletons[sequence.CurrentFrame];
331331
this.DrawBonesAndJoints(skeleton, dc);
332332

333-
if (frameCount % 4 == 0)
333+
if (frameCount % 2 == 0)
334334
{
335335
sequence.CurrentFrame++;
336336
}
@@ -355,25 +355,6 @@ private void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArg
355355
}
356356
}
357357

358-
lock (lockObj)
359-
{
360-
List<GhostSkeletonSequence> toRemove = new List<GhostSkeletonSequence>();
361-
foreach (GhostSkeletonSequence sequence in activeSequences)
362-
{
363-
if (sequence.CurrentFrame >= sequence.SavedSkeletons.Count - 1)
364-
{
365-
sequence.CurrentFrame = 0;
366-
toRemove.Add(sequence);
367-
continue;
368-
}
369-
370-
GhostSkeleton skeleton = sequence.SavedSkeletons[sequence.CurrentFrame];
371-
sequence.CurrentFrame++;
372-
}
373-
374-
toRemove.ForEach(sequence => activeSequences.Remove(sequence));
375-
}
376-
377358
// Used to determine when skeletons move off the screen
378359
List<int> unseenTrackingIDs = this.trackingIDsToSequences.Keys.ToList();
379360

@@ -400,8 +381,6 @@ private void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArg
400381

401382
sequence.AddSkeleton(skel);
402383
}
403-
404-
//this.DrawBonesAndJoints(skel, dc);
405384
}
406385
}
407386

0 commit comments

Comments
 (0)