3 Replies Latest reply on Apr 5, 2017 2:36 AM by MartyG

    How can I use the depth camera of RS300 with MATLAB?

    KUResearcher

      When I try to open the depth camera with MATLAB, I get green image.

      Is there a way to work with the depth camera in MATLAB?

       

      Thanks.

        • 1. Re: How can I use the depth camera of RS300 with MATLAB?
          MartyG

          There is not much information on the RealSense forums about using the camera with MATLAB.  RealSense expert Samontab's opinion was that a direct streaming of the camera data into MATLAB was not viable, and you should instead "use the RealSense SDK to get the correct depth value and export it into MATLAB."

           

          Streaming Depth into Matlab

           

          Intel support staff member Jesus Garcia's thoughts on the issue were that "The [RealSense] SDK team does not support Matlab integration."  Which is another way of saying, I guess, that you need to export the data into MATLAB somehow.  A support member on the MATLAB forum confirmed that - at the time of writing his message in October 2015 - that MATLAB did not yet support RealSense.

           

          Here's a link to somebody else who had a green image when trying to stream a RealSense depth image into MATLAB.

           

          How do I interpret an Intel Realsense camera depth map in MATLAB? - Stack Overflow

           

          A developer on GitHub has apparently written an adapter to get MATLAB to work with RealSense streams, though it was written for the SR300's predecessor the F200 so I cannot guarantee it will work.

           

          GitHub - gameinskysky/RealSenseImaq: Real Sense Adaptor

          1 of 1 people found this helpful
          • 2. Re: How can I use the depth camera of RS300 with MATLAB?
            HelloIntelWorld

            I have managed to do it. Try to use "imaqtool" in matlab to get the depth data directly. If you use the function "imshow" to display one image directly, it may be too dark. Thus I try to multiplied by a constant 100 to show the image.

            SR300 depth.png

            Here is my code.

             

            % 2017-03-31 by LSS

            clc; clear;

            % vidDepth = imaq.VideoDevice('winvideo', 2);

            % vidColor = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480');

            vidDepth = imaq.VideoDevice('winvideo', 1, 'Z16 _628x469');

            vidColor = imaq.VideoDevice('winvideo', 2);

            hVideoDepth = vision.VideoPlayer;

            hVideoDepth.Name  = 'depth';

            hVideoColor = vision.VideoPlayer;

            hVideoColor.Name  = 'color';

            nFrames = 0;

            while (nFrames < 500)

                DepthFrame = 100 * step(vidDepth);

                step(hVideoDepth, DepthFrame);

                step(hVideoColor, step(vidColor));

                nFrames = nFrames + 1;

            end

            release(vidDepth);

            release(vidColor);

            release(hVideoDepth);

            release(hVideoColor);

            close all force;

            fprintf('end\n');

            1 of 1 people found this helpful
            • 3. Re: How can I use the depth camera of RS300 with MATLAB?
              MartyG

              Awesome, thanks so much for sharing your experience and your script