Items with no label
3335 Discussions

vertices values are all zero from QueryVertices

MJala
Novice
1,108 Views

I have the following code:

/***

 

Reads the depth data from the sensor and fills in the matrix

 

***/

 

void SR300Camera::fillInZCoords()

 

{

 

//int res = pmdGet3DCoordinates(hnd, dists, 3 * numPixels * sizeof(float)); //store x,y,z coordinates dists (type: float*)

 

////float * zCoords = new float[1]; //store z-Coordinates of dists in zCoords

 

//xyzMap = cv::Mat(xyzMap.size(), xyzMap.type(), dists);

 

Projection *projection = pp->QueryCaptureManager()->QueryDevice()->CreateProjection();

 

std::vector vertices;

 

vertices.resize(depth_width * depth_height);

 

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

 

xyzBuffer.clear();

 

//for (int i = 0; i < bufferSize.width*bufferSize.height; i++) {

 

for (int i=0; i< depth_width*depth_height; i++) {

 

//cv::Point3f p;

 

//p.x = vertices[i].x;

 

//p.y = vertices[i].y;

 

//p.z = vertices[i].z;

 

//xyzBuffer.push_back(p);

 

cout << "x= " << vertices[i].x << endl;<p>  cout << "y= " << vertices[i].y << endl;<p>  cout << "z= " << vertices[i].z << endl;

xyzBuffer.push_back(cv::Point3f(vertices[i].x, vertices[i].y, vertices[i].z));

 

}

xyzMap = cv::Mat(xyzBuffer);

 

cout << "xyzMap = " << endl << " " << xyzMap << endl << endl;

projection->Release();

 

}

it returns zero for all the x, y, z. Basically, I am trying to write the same function as below for RealSense:

void PMDCamera::fillInZCoords()

{

int res = pmdGet3DCoordinates(hnd, dists, 3 * numPixels * sizeof(float)); //store x,y,z coordinates dists (type: float*)

//float * zCoords = new float[1]; //store z-Coordinates of dists in zCoords

xyzMap = cv::Mat(xyzMap.size(), xyzMap.type(), dists);

}

Any thought on how to fix my RealSense counterpart to get the correct values instead of zero is really appreciated.

cv::Mat xyzMap;

std::vector xyzBuffer;

My question is similar to https://software.intel.com/en-us/forums/realsense/topic/675750 The PXCProjection::ProjectDepthToCamera function in that I am trying to get the xyzMap from the realsense. Unfortunately, I couldn't find a working piece of code yet for so.

0 Kudos
4 Replies
idata
Employee
261 Views

Hi MonaJalal,

 

 

Thanks for your interest in the Intel RealSense Technology.

 

 

I'd like to suggest you to take a look at this other thread: /message/468049# 468049 how can i change sr300 hw setting room hand face body, there is a discussion regarding the value of the vertices that they are sometimes (0,0,0) or (-1,-1-,1) depending on the distance from the object to the camera, please look at that thread for more information. Also, if I'm right, you are using the SR300 camera (looking at your code), which its range is .2m – 1.5m, so you could test if at different distances you still get 0 values.

 

 

Hope this information helps.

 

 

Regards,

 

-Yermi A.

 

0 Kudos
MJala
Novice
261 Views

Hi Yermi,

The values from posUVZ are non-zero and when fed to projection->ProjectDepthToCamera(wxhDepth, posUVZ, pos3D); they all become zero. I have tested the projection separately and it never errs.

http://stackoverflow.com/questions/43991565/all-the-pos3d-values-are-zero-while-posuvz-values-are-not-zero c++ - all the pos3d values are zero while posUVZ values are not zero - Stack Overflow

Any insight about what goes wrong in that method?

Thanks,

Mona Jalal

0 Kudos
idata
Employee
261 Views

Hi MonaJalal,

 

 

Please let us investigate a little bit more regarding that and as soon as I have useful information I'll let you know.

 

 

I'll appreciate your patience during the meantime.

 

 

Regards,

 

-Yermi A.

 

0 Kudos
idata
Employee
261 Views

Hi MonaJalal,

 

 

I have noticed that you have this other thread: /message/474808# 474808 why all the pos3d values are zero while posUVZ values are not zero and how to fix it?, regarding the same issue. I'd like to let you know that in order to avoid duplicates I'll close this thread and you will be helped by Leonardo in the other one.

 

 

Regards,

 

-Yermi A.

 

0 Kudos
Reply