xxyxxy
1
Hi! I am doing a pretty bad job at finding the documentation for the C# API, I apologize in advance.
I am trying to use the CoordinateMapper in Unity, but I just can’t figure it out.
In the C++ examples the DepthStream has a member variable that is a CoordinateMapper so I tried that first.
After guessing and checking for a while, I decided to use ildasm to see what the actual C# assembly contained.
There is only one constructor for CoordinateMapper and it takes two ints and two floats.
What do these arguments mean? Has anybody successfully used CoordinateMapper in the C# API?
pkr97
2
Hi this is in C++…
if (depthFrame.is_valid())
{
int width = depthFrame.width();
int height = depthFrame.height();
int frameIndex = depthFrame.frame_index();
//determine if buffer needs to be reallocated
if (width != lastWidth_ || height != lastHeight_)
{
buffer_ = buffer_ptr(new int16_t[depthFrame.length()]);
lastWidth_ = width;
lastHeight_ = height;
}
depthFrame.copy_to(buffer_.get());
size_t index = ((width * (height / 2.0f)) + (width / 2.0f));
short middle = buffer_[index];
float worldX, worldY, worldZ;
float depthX, depthY, depthZ;
mapper.convert_depth_to_world(width / 2.0f, height / 2.0f, middle, &worldX, &worldY, &worldZ);
mapper.convert_world_to_depth(worldX, worldY, worldZ, &depthX, &depthY, &depthZ);
std::cout << "depth frameIndex: " << frameIndex
<< " value: " << middle
<< " wX: " << worldX
<< " wY: " << worldY
<< " wZ: " << worldZ
<< " dX: " << depthX
<< " dY: " << depthY
<< " dZ: " << depthZ
<< std::endl;
}
from an example “DepthReaderEventCPP”…
Hope this helps…
BR,
Prasanna