4 Replies Latest reply on May 14, 2018 12:57 AM by MartyG

    RealSense, best way to get C# eventbased new frames.


      Working width the SDK2.0 examples.
      I notice from these examples that there is a huge using verb in which the whole program is contained

      using (var ctx = new Context()) { .....


      in which everything happens in a while(true)

      In those example you get :

      using (var f = q.WaitForFrame() as VideoFrame)



      //program flow continous width f a int depth array.

      Width camera's its more common to create something events based upon new arrival of frames.
      So that other applications can consume such events easily.
      Like below i show some kinect code parts (but other camera's work usually similar).
      ea :


      DepthFrameReader  depthFrameReader = kinectSensor.DepthFrameSource.OpenReader();

      depthFrameReader.FrameArrived += DepthFrameReader_FrameArrived;

      ...// then later on in the code :

      private void DepthFrameReader_FrameArrived(object sender, DepthFrameArrivedEventArgs e)


             DepthFrameReference frameReference = e.FrameReference;
             DepthFrame frame = frameReference.AcquireFrame();
            // ... well it becomes a bit kinect specific though the main idea then is one can work width e the frame data.



      I'm kinda wondered that there is no Event construction like that inside the SDK, and wonder what's the shortest way to include it.
      So it fits more easily into existing (kinect based) code.
      I wasn't sure where to post this (but this forum is for developers as well I assume, although there is no code highlighting here  ?)

        • 1. Re: RealSense, best way to get C# eventbased new frames.

          What i mean is something close to below  (draft not checked code)



          public class RSVideoHandler


          public delegate void VideoUpdateHandler(object sender, VideoEventArgs e);

          private VideoFrame RSFrameIntern;

          public void UpdateNewFrame(VideoFrame frame)


            if (OnUpdateStatus == null) return;

            VideoEventArgs RSFrameIntern = new VideoEventArgs(frame);


          public class VideoEventArgs : EventArgs


             public VideoFrame RSFrame { get; private set; }

             public VideoEventArgs(VideoFrame frame)


              RSFrame = frame;




          Might as well create a continuous thread, In which we now can Raise an Event so a consumer can use it, in fact the RSVideoHandler class could as well have a Init/constructor function to set it up as wrapper around the wrapper
          But wrappers around wrappers wouldnt.....not my first choise. unless i miss something in this SDK that above wouldnt be required for solving this.


          (BTW its not uncommon to have some /// above functions inside an SDK so it becomes a bit more readable.)

          • 2. Re: RealSense, best way to get C# eventbased new frames.
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hello IndustrialPeter, 

            Have you tested the capabilities in this sample? 


            In this example, we align depth frames to their corresponding color frames. Then, we use the two frames to determine the depth of each color pixel.

            Using this information, we "remove" the background of the color frame that is further (away from the camera) than some user-define distance.

            The example displays a GUI for controlling the maximum distance to show from the original color image.

            Hope this example helps. 

            Best Regards, 
            Juan N.

            • 3. Re: RealSense, best way to get C# eventbased new frames.

              Yes I looked at it the sample doesnt seam to be event driven either.

              I was under the impression that microsoft was advicing realsense, and helped you guys in this tech, in a colaboration.
              However the depth technique difffers, code doesnt match (not even a little), and Microsoft just released a new Kinnect, (Kinnect azure) at their developers days.
              I got this one running now (i wrote an event based driver), and while the kinnect is in order, i'll just play a bit width this one.
              It works reasonable (a bit low depth resolution) for outdoor situation (kinect one not, but kinnect azure is promises a TOF that does that too).
              So exciting times....


              Maybe I dont know exactly how the opensource Git works, i might post the event driven code.
              Its verry basic but well thats what it should be too for a example, a simple class to retrieve frames.

              • 4. Re: RealSense, best way to get C# eventbased new frames.

                Yes, the new Kinect for Azure is coming in 2019.  An Intel webinar in March gave details of Intel's own RealSense plans up to 2020.


                RealSense 400 Series life cycle and future roadmap


                So as you say, exciting times! 


                Microsoft are naturally going to be supporting their own camera product well.  I would expect collaboration between Microsoft and Intel on RealSense to continue as normal though, as the Microsoft of modern times is very open to partnerships with other companies (such as mixed-reality Windows VR headsets by a number of different manufacturers).