C# Class Tango.TangoSupport

Contains the Project Tango Support Unity API. The Project Tango Support Unity API provides helper methods useful to external developers for manipulating Project Tango data. The Project Tango Support Unity API is experimental and subject to change.
Show file Open project: stetro/project-tango-poc Class Usage Examples

Public Methods

Method Description
FitPlaneModelNearClick ( Vector3 pointCloud, int pointCount, double timestamp, TangoCameraIntrinsics cameraIntrinsics, Matrix4x4 &matrix, Vector2 uvCoordinates, Vector3 &intersectionPoint, Plane &plane ) : int

Fits a plane to a point cloud near a user-specified location. This occurs in two passes. First, all points in cloud within maxPixelDistance to uvCoordinates after projection are kept. Then a plane is fit to the subset cloud using RANSAC. After the initial fit all inliers from the original cloud are used to refine the plane model.

ScreenCooordinateToWorldBilateral ( Vector3 pointCloud, int pointCount, double timestamp, TangoCameraIntrinsics cameraIntrinsics, TangoImageBuffer colorImage, Matrix4x4 &matrix, Vector2 uvCoordinates, Vector3 &colorCameraPoint, bool &isValidPoint ) : int

Calculates the depth in the color camera space at a user-specified location using bilateral filtering weighted by both spatial distance from the user coordinate and by intensity similarity.

ScreenCoordinateToWorldNearestNeighbor ( Vector3 pointCloud, int pointCount, double timestamp, TangoCameraIntrinsics cameraIntrinsics, Matrix4x4 &matrix, Vector2 uvCoordinates, Vector3 &colorCameraPoint, bool &isValidPoint ) : int

Calculates the depth in the color camera space at a user-specified location using nearest-neighbor interpolation.

TangoPoseToWorldTransform ( TangoPoseData poseData, Vector3 &position, Quaternion &rotation ) : void

Convert a TangoPoseData into the Unity coordinate system. This only works on TangoPoseData that describes the device with respect to the start of service or area description. The result position and rotation can be used to set Unity's Transform.position and Transform.rotation.

UpdateCurrentRotationIndex ( ) : void

Update current rotation index. This function will make a query from native Android and decide what is the current screen orientation.

Private Methods

Method Description
GetDepthAtPointNearestNeighbor ( Vector3 pointCloud, int pointCount, double timestamp, TangoCameraIntrinsics cameraIntrinsics, Matrix4x4 &matrix, Vector2 uvCoordinates, Vector3 &colorCameraPoint, bool &isValidPoint ) : int

Method Details

FitPlaneModelNearClick() public static method

Fits a plane to a point cloud near a user-specified location. This occurs in two passes. First, all points in cloud within maxPixelDistance to uvCoordinates after projection are kept. Then a plane is fit to the subset cloud using RANSAC. After the initial fit all inliers from the original cloud are used to refine the plane model.
public static FitPlaneModelNearClick ( Vector3 pointCloud, int pointCount, double timestamp, TangoCameraIntrinsics cameraIntrinsics, Matrix4x4 &matrix, Vector2 uvCoordinates, Vector3 &intersectionPoint, Plane &plane ) : int
pointCloud Vector3 /// The point cloud. Cannot be null and must have at least three points. ///
pointCount int /// The number of points to read from the point cloud. ///
timestamp double The timestamp of the point cloud.
cameraIntrinsics TangoCameraIntrinsics /// The camera intrinsics for the color camera. Cannot be null. ///
matrix UnityEngine.Matrix4x4 /// Transformation matrix of the color camera with respect to the Unity /// World frame. ///
uvCoordinates Vector2 /// The UV coordinates for the user selection. This is expected to be /// between (0.0, 0.0) and (1.0, 1.0). ///
intersectionPoint Vector3 /// The output point in depth camera coordinates that the user selected. ///
plane UnityEngine.Plane The plane fit.
return int

ScreenCooordinateToWorldBilateral() public static method

Calculates the depth in the color camera space at a user-specified location using bilateral filtering weighted by both spatial distance from the user coordinate and by intensity similarity.
public static ScreenCooordinateToWorldBilateral ( Vector3 pointCloud, int pointCount, double timestamp, TangoCameraIntrinsics cameraIntrinsics, TangoImageBuffer colorImage, Matrix4x4 &matrix, Vector2 uvCoordinates, Vector3 &colorCameraPoint, bool &isValidPoint ) : int
pointCloud Vector3 /// The point cloud. Cannot be null and must have at least one point. ///
pointCount int /// The number of points to read from the point cloud. ///
timestamp double The timestamp of the depth points.
cameraIntrinsics TangoCameraIntrinsics /// The camera intrinsics for the color camera. Cannot be null. ///
colorImage TangoImageBuffer /// The color image buffer. Cannot be null. ///
matrix UnityEngine.Matrix4x4 /// Transformation matrix of the color camera with respect to the Unity /// World frame. ///
uvCoordinates Vector2 /// The UV coordinates for the user selection. This is expected to be /// between (0.0, 0.0) and (1.0, 1.0). ///
colorCameraPoint Vector3 /// The point (x, y, z), where (x, y) is the back-projection of the UV /// coordinates to the color camera space and z is the z coordinate of /// the point in the point cloud nearest to the user selection after /// projection onto the image plane. If there is not a point cloud point /// close to the user selection after projection onto the image plane, /// then the point will be set to (0.0, 0.0, 0.0) and isValidPoint will /// be set to false. ///
isValidPoint bool /// A flag valued true if there is a point cloud point close to the user /// selection after projection onto the image plane and valued false /// otherwise. ///
return int

ScreenCoordinateToWorldNearestNeighbor() public static method

Calculates the depth in the color camera space at a user-specified location using nearest-neighbor interpolation.
public static ScreenCoordinateToWorldNearestNeighbor ( Vector3 pointCloud, int pointCount, double timestamp, TangoCameraIntrinsics cameraIntrinsics, Matrix4x4 &matrix, Vector2 uvCoordinates, Vector3 &colorCameraPoint, bool &isValidPoint ) : int
pointCloud Vector3 /// The point cloud. Cannot be null and must have at least one point. ///
pointCount int /// The number of points to read from the point cloud. ///
timestamp double The timestamp of the depth points.
cameraIntrinsics TangoCameraIntrinsics /// The camera intrinsics for the color camera. Cannot be null. ///
matrix UnityEngine.Matrix4x4 /// Transformation matrix of the color camera with respect to the Unity /// World frame. ///
uvCoordinates Vector2 /// The UV coordinates for the user selection. This is expected to be /// between (0.0, 0.0) and (1.0, 1.0). ///
colorCameraPoint Vector3 /// The point (x, y, z), where (x, y) is the back-projection of the UV /// coordinates to the color camera space and z is the z coordinate of /// the point in the point cloud nearest to the user selection after /// projection onto the image plane. If there is not a point cloud point /// close to the user selection after projection onto the image plane, /// then the point will be set to (0.0, 0.0, 0.0) and isValidPoint will /// be set to false. ///
isValidPoint bool /// A flag valued true if there is a point cloud point close to the user /// selection after projection onto the image plane and valued false /// otherwise. ///
return int

TangoPoseToWorldTransform() public static method

Convert a TangoPoseData into the Unity coordinate system. This only works on TangoPoseData that describes the device with respect to the start of service or area description. The result position and rotation can be used to set Unity's Transform.position and Transform.rotation.
public static TangoPoseToWorldTransform ( TangoPoseData poseData, Vector3 &position, Quaternion &rotation ) : void
poseData TangoPoseData /// The input pose data that is going to be converted, please note that /// the pose data has to be in the start of service with respect to /// device frame. ///
position Vector3 The result position data.
rotation UnityEngine.Quaternion The result rotation data.
return void

UpdateCurrentRotationIndex() public static method

Update current rotation index. This function will make a query from native Android and decide what is the current screen orientation.
public static UpdateCurrentRotationIndex ( ) : void
return void