private void FrameCollection_CollectionProgressed(ExampleMediaFrameCollection sender, ExampleMediaFrameCollectionProgressedEventArgs args) { if (args.Frame.SourceKind == MediaFrameSourceKind.Color) { ColorFrameEpochs.Enqueue(args.Frame.SystemRelativeTime.Value); if (ColorFrameEpochs.Count > 10) { ColorFrameEpochs.TryDequeue(out _); } } else if (args.Frame.SourceKind == MediaFrameSourceKind.Infrared) { if (args.Frame.IsIlluminated == true) { IlluminatedInfraredFrameEpochs.Enqueue(args.Frame.SystemRelativeTime.Value); if (IlluminatedInfraredFrameEpochs.Count > 10) { IlluminatedInfraredFrameEpochs.TryDequeue(out _); } } else { NonIlluminatedInfraredFrameEpochs.Enqueue(args.Frame.SystemRelativeTime.Value); if (NonIlluminatedInfraredFrameEpochs.Count > 10) { NonIlluminatedInfraredFrameEpochs.TryDequeue(out _); } } } // Must either dispose or take ownership of the frame args.Frame.Dispose(); }
private void RawStats(MediaFrameReference frame) { if (frame == null) { return; } if (frame.SystemRelativeTime == null) { return; } if (frame.SourceKind == MediaFrameSourceKind.Color) { ColorFrameEpochs.Enqueue(frame.SystemRelativeTime.Value); if (ColorFrameEpochs.Count > 10) { ColorFrameEpochs.TryDequeue(out _); } } else if (frame.SourceKind == MediaFrameSourceKind.Infrared && frame.VideoMediaFrame != null && frame.VideoMediaFrame.InfraredMediaFrame != null) { if (frame.VideoMediaFrame.InfraredMediaFrame.IsIlluminated == true) { IlluminatedInfraredFrameEpochs.Enqueue(frame.SystemRelativeTime.Value); if (IlluminatedInfraredFrameEpochs.Count > 10) { IlluminatedInfraredFrameEpochs.TryDequeue(out _); } } else { NonIlluminatedInfraredFrameEpochs.Enqueue(frame.SystemRelativeTime.Value); if (NonIlluminatedInfraredFrameEpochs.Count > 10) { NonIlluminatedInfraredFrameEpochs.TryDequeue(out _); } } } }