Skip to content

Commit 1fce8ed

Browse files
author
Dustin Hopper
committed
OniStream:convertDepthToWorldCoordinates
Function now checks the stream pixel format to return millimeters if the pixel format is set to PIXEL_FORMAT_DEPTH_100_UM
1 parent 6857677 commit 1fce8ed

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Source/Core/OniStream.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,15 @@ OniStatus VideoStream::convertDepthToWorldCoordinates(float depthX, float depthY
399399
float normalizedX = depthX / m_worldConvertCache.resolutionX - .5f;
400400
float normalizedY = .5f - depthY / m_worldConvertCache.resolutionY;
401401

402-
*pWorldX = normalizedX * depthZ * m_worldConvertCache.xzFactor;
403-
*pWorldY = normalizedY * depthZ * m_worldConvertCache.yzFactor;
404-
*pWorldZ = depthZ;
402+
OniVideoMode videoMode;
403+
int size = sizeof(videoMode);
404+
getProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, &videoMode, &size);
405+
406+
float const convertToMillimeters = (videoMode.pixelFormat == ONI_PIXEL_FORMAT_DEPTH_100_UM) ? 10.f : 1.f;
407+
*pWorldX = (normalizedX * depthZ * m_worldConvertCache.xzFactor) / convertToMillimeters;
408+
*pWorldY = (normalizedY * depthZ * m_worldConvertCache.yzFactor) / convertToMillimeters;
409+
*pWorldZ = depthZ / convertToMillimeters;
410+
405411
return ONI_STATUS_OK;
406412
}
407413

0 commit comments

Comments
 (0)