问题
We are trying to get the Point Cloud Unity example to work. We tried both the example from the git: https://github.com/googlesamples/tango-examples-unity/tree/master/UnityExamples/Assets/TangoSDK/Examples/PointCloud
As well as the Depth Perception Tutorial: https://developers.google.com/project-tango/apis/unity/unity-prefab-depth
But we only get points rendered on the upper half of the screen for some reason. When we quickly tilt our device up we can see more points but as soon as the renderer catches up they disappear again.
We are pretty sure it worked with older versions but we might be mistaking. We use Unity 5.3.3 and the Unity SDK is Gemma (Version 1.31, February 2016).
Any ideas?
回答1:
the TangoDeltaPoseController and TangoPoseController in Unity all assume Unity Camera Frame was aligned with the Device (Default) Frame, so the matrix dTuc was a constant matrix
m_dTuc = new Matrix4x4();
m_dTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
m_dTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
m_dTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
m_dTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
but for AR or point cloud like apps, the overlay image or the point cloud was captured by the color/depth camera, the m_dTuc need an extra transformation instead of using the default constant matrix
in the TangoARPoseController it was
// Get the transformation of device frame with respect to IMU frame.
pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
Matrix4x4 imuTd = poseData.ToMatrix4x4();
// Get the transformation of IMU frame with respect to color camera frame.
pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_CAMERA_COLOR;
PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
Matrix4x4 imuTc = poseData.ToMatrix4x4();
// Get the transform of the Unity Camera frame with respect to the Color Camera frame.
Matrix4x4 cTuc = new Matrix4x4();
cTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
cTuc.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
cTuc.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
cTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
m_dTuc = Matrix4x4.Inverse(imuTd) * imuTc * cTuc;
I hope this would help you.
来源:https://stackoverflow.com/questions/35605687/point-cloud-unity-example-only-renders-points-for-the-upper-half-of-display