/// <summary> /// Receive a frame - blocks until an incoming frame is available. /// </summary> public FrameInfo ReceiveFrame() { FrameInfo frame; lock (ReceiveLock) { // Block until a frame is available while (_ReceivedFrames.Count < 1) { Monitor.Wait(ReceiveLock); } // Get the frame frame = _ReceivedFrames.Dequeue(); // Log that this frame is being received ReceivedFramesLog.Add(frame); } // Make sure that we don't receive the frame earlier than the specified time while (frame.Time > sw.Elapsed) { Thread.Sleep(frame.Time - sw.Elapsed); } // Notify listeners of received frame OnReceiveFrame?.Invoke(this, new FrameEventArgs(frame, sw.Elapsed)); return(frame); }
public DataListener(OnReceiveFrame onReceiveFrame, OnReceiveInstant onReceiveInstant, OnReceiveRealTimeTrack onReceiveRealTimeTrack, OnReceiveTrack onReceiveTrack) { OnReceiveFrame = onReceiveFrame; OnReceiveInstant = onReceiveInstant; OnReceiveRealTimeTrack = onReceiveRealTimeTrack; OnReceiveTrack = onReceiveTrack; }
private void ColorFrameReader_FrameArrivedAsync(MediaFrameReader sender, MediaFrameArrivedEventArgs args) { if (Enable && CaptureCD.isTimeout()) { var frame = sender.TryAcquireLatestFrame(); if (frame != null) { var inputBitmap = frame.VideoMediaFrame?.SoftwareBitmap; if (inputBitmap != null) { OnReceiveFrame?.Invoke(inputBitmap); } //inputBitmap.Dispose(); } CaptureCD.Reset(); } }