I want publish PointCloud from depth image. So, I did convert each depth point to world coordinate point.
I used DepthSensor.convertProjToRealCoords function. But, It works weird.
for(int h = 0; h < height; h++)
{
for(int w = 0; w < width; w++)
{
Vector3 data = depthSensor_->convertProjToRealCoords(w, h, depth[w * h]);
}
}
The depth data is effectively an array processed by row - so to get the correct offset into the array you need to step down by whole rows.
The start of each row ( h ) is an increment of the width, as such, row one starts at width * 0 - row two starts at width * 1, row three starts at width * 2 and so on. You then add w to get the offset into the row.
So depth [ h * width + w ] is what you are looking for.