示例#1
0
        /// <summary>
        /// This method is used to pass frame into a processing block
        /// </summary>
        /// <param name="f">frame to process</param>
        public void SubmitFrame(Frame f)
        {
            object error;

            NativeMethods.rs2_frame_add_ref(f.Handle, out error);
            NativeMethods.rs2_process_frame(Handle, f.Handle, out error);
        }
示例#2
0
        public void SubmitFrame(Frame f, FramesReleaser releaser = null)
        {
            object error;

            NativeMethods.rs2_frame_add_ref(f.m_instance.Handle, out error);
            NativeMethods.rs2_process_frame(m_instance.Handle, f.m_instance.Handle, out error);
        }
示例#3
0
        public Frame Clone()
        {
            object error;

            NativeMethods.rs2_frame_add_ref(m_instance.Handle, out error);
            return(new Frame(m_instance.Handle));
        }
示例#4
0
        public void FrameReady(Frame f)
        {
            object error;

            NativeMethods.rs2_frame_add_ref(f.m_instance.Handle, out error);
            NativeMethods.rs2_synthetic_frame_ready(m_instance.Handle, f.m_instance.Handle, out error);
        }
示例#5
0
        public FrameSet AllocateCompositeFrame(IList <Frame> frames)
        {
            if (frames == null)
            {
                throw new ArgumentNullException(nameof(frames));
            }

            IntPtr frame_refs = IntPtr.Zero;

            try {
                object error;
                int    fl = frames.Count;
                frame_refs = Marshal.AllocHGlobal(fl * IntPtr.Size);
                for (int i = 0; i < fl; i++)
                {
                    var fr = frames[i].m_instance.Handle;
                    Marshal.WriteIntPtr(frame_refs, i * IntPtr.Size, fr);
                    NativeMethods.rs2_frame_add_ref(fr, out error);
                }

                var frame_ref = NativeMethods.rs2_allocate_composite_frame(m_instance.Handle, frame_refs, fl, out error);
                return(FrameSet.Create(frame_ref));
            }
            finally
            {
                if (frame_refs != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(frame_refs);
                }
            }
        }
示例#6
0
        public void ProcessFrame(Frame f)
        {
            object error;

            NativeMethods.rs2_frame_add_ref(f.m_instance.Handle, out error);
            NativeMethods.rs2_process_frame(m_instance.Handle, f.m_instance.Handle, out error);
        }
示例#7
0
        private void FrameReady(IntPtr ptr)
        {
            object error;

            NativeMethods.rs2_frame_add_ref(ptr, out error);
            NativeMethods.rs2_synthetic_frame_ready(m_instance.Handle, ptr, out error);
        }
示例#8
0
        /// <summary>
        /// Add a reference to this frame and return a clone, does not copy data
        /// </summary>
        /// <returns>A clone of this frame</returns>
        public Frame Clone()
        {
            object error;

            NativeMethods.rs2_frame_add_ref(Handle, out error);
            return(Create(Handle));
        }
示例#9
0
        public void Enqueue(Frame f)
        {
            object error;

            NativeMethods.rs2_frame_add_ref(f.m_instance.Handle, out error);
            NativeMethods.rs2_enqueue_frame(f.m_instance.Handle, m_instance.Handle);
        }
示例#10
0
        public Frame AsFrame()
        {
            object error;

            NativeMethods.rs2_frame_add_ref(m_instance.Handle, out error);
            return(CreateFrame(m_instance.Handle));
        }
示例#11
0
        public VideoFrame Colorize(VideoFrame 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);
            return(queue.WaitForFrame() as VideoFrame);
        }
示例#12
0
        public Points Calculate(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);
            return(queue.WaitForFrame() as Points);
        }
示例#13
0
        public FrameSet Process(FrameSet 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);
            return(queue.WaitForFrames());
        }
示例#14
0
        public FrameSet Process(FrameSet original, FramesReleaser releaser = null)
        {
            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);
            return(FramesReleaser.ScopedReturn(releaser, queue.WaitForFrames() as FrameSet));
        }
示例#15
0
        public VideoFrame Colorize(VideoFrame original, FramesReleaser releaser = null)
        {
            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);
            return(FramesReleaser.ScopedReturn(releaser, queue.WaitForFrame() as VideoFrame));
        }
示例#16
0
        public void MapTexture(VideoFrame texture)
        {
            object error;

            Options[Option.TextureSource].Value = Convert.ToSingle(texture.Profile.UniqueID);
            NativeMethods.rs2_frame_add_ref(texture.m_instance.Handle, out error);
            NativeMethods.rs2_process_frame(m_instance.Handle, texture.m_instance.Handle, out error);
        }
示例#17
0
        public Points Calculate(Frame original, FramesReleaser releaser = null)
        {
            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);
            return(FramesReleaser.ScopedReturn(releaser, queue.WaitForFrame() as Points));
        }
示例#18
0
        /// <summary>Returns a strongly-typed clone</summary>
        /// <typeparam name="T"><see cref="Frame"/> type or subclass</typeparam>
        /// <param name="other"><see cref="Frame"/> to clone</param>
        /// <returns>an instance of <typeparamref name="T"/></returns>
        public static T Create <T>(Frame other)
            where T : Frame
        {
            object error;

            NativeMethods.rs2_frame_add_ref(other.Handle, out error);
            return(ObjectPool.Get <T>(other.Handle));
        }
        /// <summary>
        /// This method is used to pass frames into a processing block
        /// </summary>
        /// <typeparam name="T"><see cref="Frame"/> type or subclass</typeparam>
        /// <param name="f">Frame to process</param>
        public void Process <T>(T f)
            where T : Frame
        {
            object error;

            NativeMethods.rs2_frame_add_ref(f.Handle, out error);
            NativeMethods.rs2_process_frame(m_instance.Handle, f.Handle, out error);
        }
示例#20
0
        public void MapTo(Frame mapped)
        {
            this.Options.Where(s => s.Key == Option.TextureSource).First().Value = mapped.Profile.UniqueID;
            object error;

            NativeMethods.rs2_frame_add_ref(mapped.m_instance.Handle, out error);
            NativeMethods.rs2_process_frame(m_instance.Handle, mapped.m_instance.Handle, out error);
        }
示例#21
0
 public T As <T>() where T : Frame
 {
     using (this)
     {
         object error;
         NativeMethods.rs2_frame_add_ref(m_instance.Handle, out error);
         return(Create <T>(m_instance.Handle));
     }
 }
示例#22
0
 public static FrameSet FromFrame(Frame composite)
 {
     if (composite.IsComposite)
     {
         object error;
         NativeMethods.rs2_frame_add_ref(composite.m_instance.Handle, out error);
         return(FrameSet.Pool.Get(composite.m_instance.Handle));
     }
     throw new ArgumentException("The frame is a not composite frame", nameof(composite));
 }
示例#23
0
        public void MapTexture(VideoFrame texture)
        {
            object error;

            Options[Option.StreamFilter].Value       = Convert.ToSingle(texture.Profile.Stream);
            Options[Option.StreamFormatFilter].Value = Convert.ToSingle(texture.Profile.Format);
            Options[Option.StreamIndexFilter].Value  = Convert.ToSingle(texture.Profile.Index);
            NativeMethods.rs2_frame_add_ref(texture.m_instance.Handle, out error);
            NativeMethods.rs2_process_frame(m_instance.Handle, texture.m_instance.Handle, out error);
        }
示例#24
0
        public static FrameSet FromFrame(Frame composite, FramesReleaser releaser = null)
        {
            object error;

            if (NativeMethods.rs2_is_frame_extendable_to(composite.m_instance.Handle,
                                                         Extension.CompositeFrame, out error) > 0)
            {
                NativeMethods.rs2_frame_add_ref(composite.m_instance.Handle, out error);
                return(FramesReleaser.ScopedReturn(releaser, new FrameSet(composite.m_instance.Handle)));
            }
            throw new Exception("The frame is a not composite frame");
        }
示例#25
0
        public FrameSet AllocateCompositeFrame(FramesReleaser releaser, params Frame[] frames)
        {
            object error;
            var    frame_refs = frames.Select(x => x.m_instance.Handle).ToArray();

            foreach (var fref in frame_refs)
            {
                NativeMethods.rs2_frame_add_ref(fref, out error);
            }
            var frame_ref = NativeMethods.rs2_allocate_composite_frame(m_instance.Handle, frame_refs, frames.Count(), out error);

            return(FramesReleaser.ScopedReturn(releaser, new FrameSet(frame_ref)));
        }
示例#26
0
        /// <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);
        }
示例#27
0
        /// <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");
        }