9 Replies Latest reply on Feb 7, 2018 4:36 PM by Intel Corporation

    D435 camera

    likenric

      Hi,

       

      Just a couple of basic questions on Realsense D435 camera:

       

      1. Is the camera supported in both RealSense SDK for Linux as well as the Librealsense SDK?

       

      2. What is the best and quickest way to convert the frames captured and convert to mpeg format video?

       

      Thanks.

        • 1. Re: D435 camera
          MartyG

          1.  The D435 camera uses the new RealSense SDK 2.0, which is an advanced form of Librealsense and is a cross-platform SDK that can be used with Windows, Linux and Mac OS High Sierra.  The RealSense SDK For Linux is just for the ZR300 camera model.

           

          Releases · IntelRealSense/librealsense · GitHub

           

          2.  SDK 2.0 supports recording data to a 'bag' file.

           

          librealsense/readme.md at master · IntelRealSense/librealsense · GitHub

           

          or to a PNG.

           

          librealsense/examples/save-to-disk at master · IntelRealSense/librealsense · GitHub 

           

          You may then be able to turn the PNG into an mpeg.  Google 'convert png to mpeg' for more details.

          • 2. Re: D435 camera
            likenric

            Thank you Marty,

             

            If using the C# wrapper, after obtaining the single VideoFrame, will the following mechanism work to save the frame as png?

             

            // get VideoFrame from the pipeline.WaitForFrames()

            var bytes = new byte[frame.Stride * frame.Height]

            frame.CopyTo(bytes);

             

            MemoryStream ms = new MemoryStream(bytes);

            Image img = Image.FromStream(ms);

            image.save("filename)")

             

            I am doing prelimary investigation before we receive the camera being ordered.  Thanks!

            • 3. Re: D435 camera
              MartyG

              RealSense SDK 2.0 currently supports using C++ and C.  I believe that "C" refers to the original version of the language though, not C#.  They may currently be working on a C# wrapper, given that C was only added in the most recent release, but I have no information about that.

               

              I believe that when you mention a C# wrapper, you are referring to this?

               

              GitHub - andrecarlucci/openrealsense: .net wrapper for the librealsense

               

              Whilst that wrapper would work with the original Librealsense (now known as the Legacy version), it likely would not work with SDK 2.0 without adaptations.   An official C# wrapper may arrive before this unofficial wrapper can be converted.

              • 4. Re: D435 camera
                likenric

                Hi Marty,

                 

                I am actually referring to this:

                 

                librealsense/wrappers/csharp at master · IntelRealSense/librealsense · GitHub

                 

                It is part of the 2.0 open source project I believe.

                • 5. Re: D435 camera
                  MartyG

                  Interesting!  I had forgotten that some people use the terms C# and .NET together (e.g "I wish there was C# support as I really need .NET integration).  Thanks so much for bringing that to my attention.    It might make it clearer to SDK 2.0 users if the Releases download page refers to '.NET / C#' compatibility instead of just '.NET'

                  • 6. Re: D435 camera
                    likenric

                    Hi Marty,

                     

                    Yes.  So is this wrapper working with sdk 2.0?

                     

                    Just to get back to the original question.  I checked the wrapper sample code for Capture Image example in .net c#:

                     

                    librealsense/Window.xaml.cs at master · IntelRealSense/librealsense · GitHub

                     

                    The sample code just create the bitmap for display from the frame data (rgb 24, height is the frame.Stride and frame.Height).  If to save as a file, can we create a 24 rgb bitmap c# Bitmap object?   Just like the methods below.

                     

                    And is the width always frame.Stride?

                     

                    ---------

                    public Bitmap CopyDataToBitmap(int height, int width, byte[] data)

                    {

                      //Here create the Bitmap to the know height, width and format

                      Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb); 

                     

                      //Create a BitmapData and Lock all pixels to be written

                      BitmapData bmpData = bmp.LockBits(

                                           new Rectangle(0, 0, bmp.Width, bmp.Height),  

                                           ImageLockMode.WriteOnly, bmp.PixelFormat);

                     

                      //Copy the data from the byte array into BitmapData.Scan0

                      Marshal.Copy(data, 0, bmpData.Scan0, data.Length);

                                   

                                   

                      //Unlock the pixels

                      bmp.UnlockBits(bmpData);

                     

                     

                      //Return the bitmap

                      return bmp;

                    }

                     

                     

                    Your help is greatly appreciated.  I am almost there just need to sort out this question on saving to use the D435.

                    • 7. Re: D435 camera
                      MartyG

                      This question is outside of my range of knowledge, regrettably.  An Intel support staff member (which I am not) should be able to give advice on it, hopefully.  Best of luck! 

                      • 8. Re: D435 camera
                        likenric

                        Hi all,

                         

                        I checked the wrapper sample code for Capture Image example in .net c#, and trying to use in D435 camera.

                         

                        librealsense/Window.xaml.cs at master · IntelRealSense/librealsense · GitHub

                         

                        The sample code just create the bitmap for display from the frame data (rgb 24, height is the frame.Stride and frame.Height).  If to save as a file, can we create a 24 rgb bitmap c# Bitmap object?   Just like the methods below.

                         

                        And is the width always frame.Stride?

                         

                        ---------

                        public Bitmap CopyDataToBitmap(int height, int width, byte[] data)

                        {

                          //Here create the Bitmap to the know height, width and format

                          Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);

                         

                          //Create a BitmapData and Lock all pixels to be written

                          BitmapData bmpData = bmp.LockBits(

                                               new Rectangle(0, 0, bmp.Width, bmp.Height), 

                                               ImageLockMode.WriteOnly, bmp.PixelFormat);

                         

                          //Copy the data from the byte array into BitmapData.Scan0

                          Marshal.Copy(data, 0, bmpData.Scan0, data.Length);

                                      

                                      

                          //Unlock the pixels

                          bmp.UnlockBits(bmpData);

                         

                         

                          //Return the bitmap

                          return bmp;

                        }

                        • 9. Re: D435 camera
                          Intel Corporation
                          This message was posted on behalf of Intel Corporation

                          Hello Kenric,

                          It is hard to tell whether your code will work. I did find this information on frame strides that may be helpful for you:

                          https://msdn.microsoft.com/en-us/library/windows/desktop/aa473780%28v=vs.85%29.aspx

                          "When a video image is stored in memory, the memory buffer might contain extra padding bytes after each row of pixels. The padding bytes affect how the image is stored in memory, but do not affect how the image is displayed.

                          The stride is the number of bytes from one row of pixels in memory to the next row of pixels in memory. "


                          Regards,
                          Jesus
                          Intel Customer Support