Items with no label
3335 Discussions

Intel realsense f200 get depth unity

hothm
Novice
1,659 Views

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 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];

projection.QueryVertices(args.sample.Depth,uv);

......

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

}

}

0 Kudos
1 Solution
jb455
Valued Contributor II
372 Views

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

}

}

View solution in original post

4 Replies
MartyG
Honored Contributor III
372 Views

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.

0 Kudos
jb455
Valued Contributor II
373 Views

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

}

}

jb455
Valued Contributor II
372 Views

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:

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

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.

0 Kudos
MartyG
Honored Contributor III
372 Views
0 Kudos
Reply