4 Replies Latest reply on Feb 13, 2017 9:34 AM by MartyG

    Intel realsense f200 get depth unity


      hi ,

      i want make something like that with intel real sense F200 https://software.intel.com/en-us/articles/tanked-by-design-mill-a-4d-video-game-using-intel-realsense-technology


      my solution it was to transfrom Image DEPth to Point3DF32 with QueryVertices , but i don't get good values:



                   uv = new Point3DF32[dinfo.width * dinfo.height];




      n = new float[512, 512];


        for (int x = 0; x <512 ; x++)


                      for (int y = 0; y < 512; y++)


      terrain.terrainData.SetHeights(0, 0, uv );

        n[x, y] = 1 = uv[x * y].y



        • 1. Re: Intel realsense f200 get depth unity

          Contributor JB455 recently provided a script that works with SR-300 to return a float value instead of an int (though it does not work with R200 cameras).  As the F200 though is the predecessor of the SR-300, maybe JB's script will work for you.


          Re: Getting float depth data

          • 2. Re: Intel realsense f200 get depth unity

            QueryVertices should give you the float depth values so you shouldn't have any problems there (I needed to get them aligned to the colour image so that's where my complication was).

            It looks like the problem is with how you're getting values out of the vertices array. Also, you're looping from 0 to 512 in x and y, but the largest depth image you can get is 640*480, so you'll get overrun there. I'd imagine you want to do something like this:


            for(int x = 0; x < dinfo.width; x++)
                 for(int y = 0; y < dinfo.height; y++
                      var vertex = uv[x + y * dinfo.width];//world coordinates for (x,y)th pixel in depth image
                      //do stuff
            1 of 1 people found this helpful
            • 3. Re: Intel realsense f200 get depth unity

              Also, if you only need depth values, not the full world coordinates (x,y,z in millimetres), you can use the following to get the depth data out of the image:


              PXCMImage.ImageData ddata;   
              args.sample.depth.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH_F32, out ddata);  
              var dwidth = depth.info.width;  
              var dheight = depth.info.height;   
              var dPixels = ddata.ToFloatArray(0, dwidth * dheight);   


              Then in your loop you'll have var z = dPixels[x + y * dwidth] to get the depth in mm for that pixel. If you're doing this each frame while streaming it'll likely be much more efficient than using QueryVertices.

              • 4. Re: Intel realsense f200 get depth unity

                Thanks so much JB!