/// <summary> /// Process frame and return the result /// </summary> /// <param name="original"></param> /// <returns></returns> public Frame Process(Frame original) { object error; NativeMethods.rs2_frame_add_ref(original.m_instance.Handle, out error); NativeMethods.rs2_process_frame(m_instance.Handle, original.m_instance.Handle, out error); Frame f; if (queue.PollForFrame(out f)) { return(f); } return(original); }
/// <summary> /// Process frame and return the result /// </summary> /// <typeparam name="T">Type of frame to return</typeparam> /// <param name="original">Frame to process</param> /// <returns>Processed frame</returns> /// <exception cref="InvalidOperationException">Thrown when errors occur during processing</exception> public T Process <T>(Frame original) where T : Frame { object error; NativeMethods.rs2_frame_add_ref(original.Handle, out error); NativeMethods.rs2_process_frame(Handle, original.Handle, out error); T f; if (queue.PollForFrame <T>(out f)) { return(f); } // this occurs when the sdk runs out of frame resources and allocate_video_frame fails // sadly, that exception doesn't propagate here... // usually a sign of not properly disposing of frames throw new InvalidOperationException($"Error while running {GetType().Name} processing block, check the log for info"); }