/// <summary> /// Handles the frame arrived event by converting the frame to a dislayable /// format and rendering it to the screen. /// Bound to the click of the Start button. /// </summary> private void Reader_FrameArrived(MediaFrameReader sender, MediaFrameArrivedEventArgs args) { // TryAcquireLatestFrame will return the latest frame that has not yet been acquired. // This can return null if there is no such frame, or if the reader is not in the // "Started" state. The latter can occur if a FrameArrived event was in flight // when the reader was stopped. using (var frame = sender.TryAcquireLatestFrame()) { _frameRenderer.ProcessFrame(frame); } }
/// <summary> /// Handles the frame arrived event by converting the frame to a displayable /// format and rendering it to the screen. /// </summary> private void Reader_FrameArrived(MediaFrameReader sender, MediaFrameArrivedEventArgs args) { using (var frame = sender.TryAcquireLatestFrame()) { UpdateStatus("Acquiring"); using (var softwareBitmap = _frameRenderer.ProcessFrame(frame)) { UpdateStatus("Recognizing"); var message = ProcessFrame(softwareBitmap); if (!string.IsNullOrEmpty(message)) { UpdateStatus("Sending " + message); Send(message); } UpdateStatus("Done"); } } }