Items with no label
3335 Discussions

R200 : xyz coordinates and 628*468 to 640*480

MOkun
Beginner
1,796 Views

I use RealSense R200 . I want to convert depth's 628*468 to 640*480 and to get 3D world coordinates(x,y,z) .

I cloud use CreateDepthImageMappedToColor regarding convert.

Next task isn't.

I certainly used QueryVertices. I use like:

PXCImage* depthIm = projection->CreateDepthImageMappedToColor(sample->depth,sample->color);

projection->QueryVertices(depthIm,vertices.data());

PXCImage::ImageInfo aa = sample->depth->QueryInfo();

But,vertices' x,y,z is all zero.And I confirmed aa.format is PIXEL_FORMAT_DEPTH_RAW

I try :

depthIm->AcquireAccess(Intel::RealSense::ImageAccess::ACCESS_READ, Intel::RealSense::PixelFormat::PIXEL_FORMAT_DEPTH, &ddata);

ddata.planes[0] is got data of 640*480.

I think ddata.planes[0] == vertices.z ,Right?

And I try another way:

PXCImage* depthIm = projection->CreateDepthImageMappedToColor(sample->depth,sample->color);

projection->QueryVertices(sample->depth,vertices.data());

Then , I can get vertices' x,y,z data. But 628*468.

Please response.

Thank you.

0 Kudos
6 Replies
jb455
Valued Contributor II
265 Views

You want to get the (x,y,z) world coordinates relative to the colour image?

Check out /thread/110837 this thread where I recently got it working (in C# but hopefully C++ isn't too different).

In the final code I ended up with the z data mapped to the colour image; I then use ProjectColorToCamera to get the (x,y,z) world coordinates.

Let me know if you need any more help!

James

0 Kudos
MOkun
Beginner
265 Views

Thank you for replying James.

I want to get depeth' s xy.

I have already get color image.

like this:

PXCImage *ColorIm = sample->color;

And I don't know how to use ProjectColorToCamera.

Would you tell me how to use about concrete arguments and the example?

I know ProjectColorToCamera.But I don't understand suitable argument.

mckie.

0 Kudos
jb455
Valued Contributor II
265 Views

To use ProjectColorToCamera we need an array of (i,j,z) points, where i and j are coordinates in the colour image, like so (following on from post # 10 /message/451113# 451113 here):

PXCMPoint3DF32[] cp = new PXCMPoint3DF32[cwidth * cheight];

PXCMPoint3DF32[] cvp = new PXCMPoint3DF32[cwidth * cheight];

for (int j = 0, k = 0; j < cheight; j++)

{

for (int i = 0; i < cwidth; i++, k++)

{

//Create 3D point with the colour (x,y) coordinates and corresponding z value

cp[k] = new PXCMPoint3DF32(i, j, mappedPixels[j * cwidth + i]);

}

}

var s = projection.ProjectColorToCamera(cp, cvp);

Now cvp contains the world coordinates, aligned to the colour image.

0 Kudos
MOkun
Beginner
265 Views
0 Kudos
jb455
Valued Contributor II
265 Views

I'd imagine numpoints will be the number of points you're sending it, ie, chieght*cwidth (or k as you already have it calculated)

0 Kudos
MOkun
Beginner
265 Views

Thank you so much!! You just said it.

I could solve my problem.

0 Kudos
Reply