Items with no label
3338 討論

Intel realsense f200 get depth unity

hothm
新手
2,024 檢視

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 積分
1 解決方案
jb455
傑出貢獻者 II
737 檢視

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

}

}

在原始文章中檢視解決方案

4 回應
MartyG
榮譽貢獻者 III
737 檢視

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.

jb455
傑出貢獻者 II
738 檢視

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
傑出貢獻者 II
737 檢視

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.

MartyG
榮譽貢獻者 III
737 檢視

Thanks so much JB!

回覆