Exemplo n.º 1
0
        /// <summary>
        /// stops streaming from specified configured device
        /// </summary>
        public void Stop()
        {
            object error;

            NativeMethods.rs2_stop(Handle, out error);
            m_callback = null;
            m_queue    = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// start streaming from specified configured sensor of specific stream to frame queue
        /// </summary>
        /// <param name="queue">frame-queue to store new frames into</param>
        // TODO: overload with state object and Action<Frame, object> callback to avoid allocations
        public void Start(FrameQueue queue)
        {
            object error;

            NativeMethods.rs2_start_queue(Handle, queue.Handle, out error);
            m_queue    = queue;
            m_callback = null;
        }
Exemplo n.º 3
0
        public void Start(FrameCallback cb)
        {
            object         error;
            frame_callback cb2 = (IntPtr f, IntPtr u) =>
            {
                using (var frame = new Frame(f))
                    cb(frame);
            };

            m_callback = cb2;
            m_queue    = null;
            NativeMethods.rs2_start(m_instance, cb2, IntPtr.Zero, out error);
        }
Exemplo n.º 4
0
        public void Start <T>(Action <T> cb) where T : Frame
        {
            object         error;
            frame_callback cb2 = (IntPtr f, IntPtr u) =>
            {
                using (var frame = Frame.Create <T>(f))
                    cb(frame);
            };

            m_callback = cb2;
            m_queue    = null;
            NativeMethods.rs2_start(m_instance, cb2, IntPtr.Zero, out error);
        }
Exemplo n.º 5
0
        public PipelineProfile Start(Config cfg, FrameCallback cb)
        {
            object         error;
            frame_callback cb2 = (IntPtr f, IntPtr u) =>
            {
                using (var frame = new Frame(f))
                    cb(frame);
            };

            m_callback = cb2;
            var res  = NativeMethods.rs2_pipeline_start_with_config_and_callback(m_instance.Handle, cfg.m_instance.Handle, cb2, IntPtr.Zero, out error);
            var prof = new PipelineProfile(res);

            return(prof);
        }
Exemplo n.º 6
0
        /// <summary>start streaming from specified configured sensor</summary>
        /// <param name="cb">delegate to register as per-frame callback</param>
        // TODO: overload with state object and Action<Frame, object> callback to avoid allocations
        public void Start(FrameCallback cb)
        {
            object         error;
            frame_callback cb2 = (IntPtr f, IntPtr u) =>
            {
                using (var frame = Frame.Create(f))
                {
                    cb(frame);
                }
            };

            m_callback = cb2;
            m_queue    = null;
            NativeMethods.rs2_start(Handle, cb2, IntPtr.Zero, out error);
        }
Exemplo n.º 7
0
        public void Start(FrameCallback cb)
        {
            object         error;
            frame_callback cb2 = (IntPtr f, IntPtr u) =>
            {
                //!TODO: check whether or not frame should be diposed here... I've got 2 concerns here:
                // 1. Best practice says that since the user's callback isn't the owner, frame should be diposed here...
                // 2. Users might need the frame for longer, but then they could clone it

                //cb(new Frame(f));
                using (var frame = new Frame(f))
                    cb(frame);
            };

            NativeMethods.rs2_start(m_instance, cb2, IntPtr.Zero, out error);
        }
Exemplo n.º 8
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    m_callback = null;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.
                Release();
                disposedValue = true;
            }
        }
Exemplo n.º 9
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    m_callback = null;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.
                NativeMethods.rs2_delete_sensor(m_instance);

                disposedValue = true;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Start the pipeline streaming with its default configuration.
        /// <para>
        /// The pipeline captures samples from the device, and delivers them to the through the provided frame callback.
        /// </para>
        /// </summary>
        /// <remarks>
        /// Starting the pipeline is possible only when it is not started. If the pipeline was started, an exception is raised.
        /// When starting the pipeline with a callback both <see cref="WaitForFrames"/> or <see cref="PollForFrames"/> will throw exception.
        /// </remarks>
        /// <param name="cb">Delegate to register as per-frame callback</param>
        /// <returns>The actual pipeline device and streams profile, which was successfully configured to the streaming device.</returns>
        // TODO: overload with state object and Action<Frame, object> callback to avoid allocations
        public PipelineProfile Start(FrameCallback cb)
        {
            object         error;
            frame_callback cb2 = (IntPtr f, IntPtr u) =>
            {
                using (var frame = Frame.Create(f))
                {
                    cb(frame);
                }
            };

            m_callback = cb2;
            var res  = NativeMethods.rs2_pipeline_start_with_callback(Handle, cb2, IntPtr.Zero, out error);
            var prof = new PipelineProfile(res);

            return(prof);
        }
Exemplo n.º 11
0
 internal static extern void rs2_set_devices_changed_callback(IntPtr context, [MarshalAs(UnmanagedType.FunctionPtr)] frame_callback callback, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Helpers.ErrorMarshaler))] out object error);
Exemplo n.º 12
0
 internal static extern void rs2_set_notifications_callback(IntPtr sensor, [MarshalAs(UnmanagedType.FunctionPtr)] frame_callback on_notification, IntPtr user, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Helpers.ErrorMarshaler))] out object error);