2 Replies Latest reply on Apr 10, 2018 10:29 AM by MartyG

    Multicam in C# -- processing the frameset

    Wiredchop

      Hello, I'm looking at processing the data from multiple cameras in C# and I have a few questions with regards to the appropriate way of processing the dataset.

       

      With a single camera

      When there's only a single camera connected, I use the Pipeline class to get a frameset

       

      pipeline = new Pipeline();
      cfg = new Config();
      PipelineProfile profile = pipeline.Start(cfg);
      frames = pipeline.WaitForFrames();
      depthframe = frames.DepthFrame;
      colourframe = frames.ColorFrame;
      

       

      To align the colour frame to the depth camera I use the Align class on the resulting frameset

      FrameSet colourindepth = align.Process(frames);
      

       

       

      With multiple cameras

      Using code snippets from the examples, for multiple cameras I'm using a different approach. (Code simplified for brevity)

      using (var ctx = new Context())
                  {
                      DeviceList cameras = ctx.QueryDevices();
                      // For now, going to loop through the cameras
                      foreach (Device camera in cameras)
                      {
                          FrameQueue depthqueue = new FrameQueue();
                            FrameQueue colourqueue = new FrameQueue();
                          SensorList sensors = camera.QuerySensors();           
                          Sensor depthsensor = sensors[0];
                          var depth_profile = depthsensor.VideoStreamProfiles.First();
                          Sensor coloursensor = sensors[1];     
                          var colour_profile = coloursensor.VideoStreamProfiles.First(); 
                          //Start sensors
                          depthsensor.Open(depth_profile);
                          depthsensor.Start(depthqueue);
                          coloursensor.Open(colour_profile);
                          coloursensor.Start(colourqueue);
      
                          // Receive frames
      
                          Frame colourframe = colourqueue.WaitForFrame();
                          Frame depthframe = depthqueue.WaitForFrame();
                      }
      }
      
      

       

      Questions

      However, in this case I only fetch a single 'Frame' object at a time. How do I align the colourframe to depth?

      I've tried to use the .waitforframeset method but it doesn't seem to be supported for this method. Also, the Align class requires a Frameset object?!

       

      How do I get a frameset in this instance? Should I be using a pipeline to get the frames? Do I pass the handle to the camera when constructing a new pipeline?

       

      Any help would be greatly appreciated

        • 1. Re: Multicam in C# -- processing the frameset
          Wiredchop

          Hello all,

           

          I've worked on this looking for a workaround and have found that the key is to stick with the pipeline method. The configuration class allows you to create a custom pipeline based on a camera's serial number

          I'm still starting with the camera context as before but this time I'm using a pipeline with a specified camera

           

          using (var ctx = new Context())  
                      {  
                          DeviceList cameras = ctx.QueryDevices();  
                          // For now, going to loop through the cameras  
                          foreach (Device camera in cameras)  
                          {  
                           cfg = new Config();  
                           cfg.Enabledevice(camera.Info[CameraInfo.SerialNumber])
                           PipelineProfile profile = pipeline.Start(cfg);  
                          }  
          
          

          Then, when you use that profile object to wait for frames, it will wait for frames from the specified device and give you a frameset you can use in an Align object.

           

          If anyone else is using C# for multicam I'd reccomend this approach.

           

          Apologies if the code is slightly wrong, it's from memory.

          1 of 1 people found this helpful
          • 2. Re: Multicam in C# -- processing the frameset
            MartyG

            Thanks so much for sharing your results with the community, Wiredchop!    C# resources are always especially welcome.