C# Class Tango.TangoApplication

Main entry point for the Tango Service. This component handles nearly all communication with the underlying TangoService. You must have one of these in your scene for Tango to work. Customization of the Tango connection can be done in the Unity editor or by programatically setting the member flags. This sends out events to Components that derive from the ITangoPose, ITangoDepth, etc. interfaces and register themselves via Register. This also sends out events to callbacks passed in through RegisterOnTangoConnect, RegisterOnTangoDisconnect, and RegisterPermissionsCallback. Note: To connect to the Tango Service, you should call InitApplication after properly registering everything.
Inheritance: UnityEngine.MonoBehaviour
显示文件 Open project: stetro/project-tango-poc Class Usage Examples

Public Properties

Property Type Description
m_3drGenerateColor bool
m_3drGenerateNormal bool
m_3drGenerateTexCoord bool
m_3drResolutionMeters float
m_3drSpaceClearing bool
m_3drUseAreaDescriptionPose bool
m_allowOutOfDateTangoAPI bool
m_autoConnectToService bool
m_enable3DReconstruction bool
m_enableADFLoading bool
m_enableAreaLearning bool
m_enableDepth bool
m_enableMotionTracking bool
m_enableVideoOverlay bool
m_motionTrackingAutoReset bool
m_videoOverlayUseByteBufferMethod bool

Private Properties

Property Type Description
Awake void
OnDestroy void
SendCloudEvent void
Update void
_CheckTangoVersion void
_FlipBitAndCheckPermissions void
_InitializeMotionTracking void
_PermissionWasDenied void
_RegisterOnAreaDescriptionEvent void
_RegisterOnExperimentalTangoVideoOverlay void
_RegisterOnTangoCloudEvent void
_RegisterOnTangoConnect void
_RegisterOnTangoDepthEvent void
_RegisterOnTangoDisconnect void
_RegisterOnTangoEvent void
_RegisterOnTangoEventMultithreaded void
_RegisterOnTangoPoseEvent void
_RegisterOnTangoVideoOverlay void
_RegisterPermissionsCallback void
_RequestNextPermission void
_ResetPermissionsFlags void
_ResumeTangoServices void
_SendPermissionEvent void
_SetDepthCallbacks void
_SetEventCallbacks void
_SetMotionTrackingCallbacks void
_SetVideoOverlayCallbacks void
_SuspendTangoServices void
_TangoConnect void
_TangoDisconnect void
_UnregisterOnAreaDescriptionEvent void
_UnregisterOnExperimentalTangoVideoOverlay void
_UnregisterOnTangoCloudEvent void
_UnregisterOnTangoConnect void
_UnregisterOnTangoDepthEvent void
_UnregisterOnTangoDisconnect void
_UnregisterOnTangoEvent void
_UnregisterOnTangoEventMultithreaded void
_UnregisterOnTangoPoseEvent void
_UnregisterOnTangoVideoOverlay void
_UnregisterPermissionsCallback void
_androidOnActivityResult void
_androidOnPause void
_androidOnResume void
_androidOnScreenOrientationChanged void

Public Methods

Method Description
GetTangoServiceVersion ( ) : string

Get the Tango service version name.

GetVideoOverlayTextureYUV ( ) : YUVTexture

Get the video overlay texture.

HasRequestedPermissions ( ) : bool

Check if all requested permissions have been granted.

Register ( object tangoObject ) : void

Register to get Tango callbacks. The object should derive from one of ITangoDepth, ITangoEvent, ITangoPos, ITangoVideoOverlay, or ITangoExperimentalTangoVideoOverlay. You will get callback during Update until you unregister.

RequestPermissions ( ) : void

Manual initialization step 1: Call this to request Tango permissions. To know the result of the permissions request, implement the interface ITangoLifecycle and register yourself before calling this. Once all permissions have been granted, you can call TangoApplication.Startup, optionally passing in the AreaDescription to load. You can get the list of AreaDescriptions once the appropriate permission is granted.

Set3DReconstructionEnabled ( bool enabled ) : void

Enable or disable the 3D reconstruction.

SetDepthCameraRate ( TangoEnums rate ) : void

Set the framerate of the depth camera. Disabling or reducing the framerate of the depth camera when it is running can save a significant amount of battery.

SetDepthCameraRate ( int rate ) : void

Set the framerate of the depth camera. Disabling or reducing the framerate of the depth camera when it is running can save a significant amount of battery.

Shutdown ( ) : void

Disconnect from the Tango service. This is called automatically when the TangoApplication goes away. You only need to call this to disconnect from the Tango service before the TangoApplication goes away.

Startup ( AreaDescription areaDescription ) : void

Manual initalization step 2: Call this to connect to the Tango service. After connecting to the Tango service, you will get updates for Motion Tracking, Depth Sensing, and Area Learning. If you have a specific Area Description you want to localize too, pass that Area Description in here.

Tango3DRClear ( ) : void

Clear the 3D reconstruction data. The reconstruction will start fresh.

Tango3DRExtractMeshSegment ( Tango3DReconstruction gridIndex, Vector3 vertices, Vector3 normals, Color32 colors, int triangles, int &numVertices, int &numTriangles ) : Tango3DReconstruction.Status

Extract a single grid cell's mesh.

Tango3DRExtractWholeMesh ( Vector3 vertices, Vector3 normals, Color32 colors, int triangles, int &numVertices, int &numTriangles ) : Tango3DReconstruction.Status

Extract a single mesh for the entire 3D reconstruction state.

Unregister ( System tangoObject ) : void

Unregister from Tango callbacks. See TangoApplication.Register for more details.

Private Methods

Method Description
Awake ( ) : void

Awake this instance.

OnDestroy ( ) : void

Unity callback when this object is destroyed.

SendCloudEvent ( string message ) : void

Propagates an event from the java plugin connected to the Cloud Service through UnitySendMessage().

Update ( ) : void

Disperse any events related to Tango functionality.

_CheckTangoVersion ( ) : void

Validate the TangoService version is supported.

_FlipBitAndCheckPermissions ( PermissionsTypes permission ) : void

Flip a permission bit and check to see if all permissions were accepted.

_InitializeMotionTracking ( string uuid ) : void

Initialize motion tracking.

_PermissionWasDenied ( ) : void

A Tango permission was denied.

_RegisterOnAreaDescriptionEvent ( OnAreaDescriptionImportEventHandler import, OnAreaDescriptionExportEventHandler export ) : void

Register to get Tango event callbacks. See TangoApplication.Register for details.

_RegisterOnExperimentalTangoVideoOverlay ( OnExperimentalTangoImageAvailableEventHandler handler ) : void

Experimental API only, subject to change. Register to get Tango video overlay callbacks.

_RegisterOnTangoCloudEvent ( OnTangoCloudEventAvailableEventHandler handler ) : void

Register to get Tango cloud event callbacks. See TangoApplication.Register for details.

_RegisterOnTangoConnect ( OnTangoConnectEventHandler handler ) : void

Register to get an event callback when connected to the Tango service. The passed event will get called once connected to the Tango service. Registering after already connected will cause the event to not fire until disconnected and then connecting again.

_RegisterOnTangoDepthEvent ( OnTangoDepthAvailableEventHandler handler ) : void

Register to get Tango depth callbacks. See TangoApplication.Register for more details.

_RegisterOnTangoDisconnect ( OnTangoDisconnectEventHandler handler ) : void

Register to get an event callback when disconnected from the Tango service. The passed event will get called when disconnected from the Tango service.

_RegisterOnTangoEvent ( OnTangoEventAvailableEventHandler handler ) : void

Register to get Tango event callbacks. See TangoApplication.Register for details.

_RegisterOnTangoEventMultithreaded ( OnTangoEventAvailableEventHandler handler ) : void

Register to get Tango event callbacks. See TangoApplication.Register for details.

_RegisterOnTangoPoseEvent ( OnTangoPoseAvailableEventHandler handler ) : void

Register to get Tango pose callbacks. See TangoApplication.Register for more details.

_RegisterOnTangoVideoOverlay ( OnTangoImageAvailableEventHandler handler ) : void

Register to get Tango video overlay callbacks. See TangoApplication.Register for details.

_RegisterPermissionsCallback ( PermissionsEvent permissionsEventHandler ) : void

Register to get an event callback when all permissions are granted. The passed event will get called once all Tango permissions have been granted. Registering after all permissions have already been granted will cause the event to never fire.

_RequestNextPermission ( ) : void

Request next permission.

_ResetPermissionsFlags ( ) : void

Reset permissions flags.

_ResumeTangoServices ( ) : void

Helper method that will resume the tango services on App Resume. Locks the config again and connects the service.

_SendPermissionEvent ( bool permissions ) : void

Sends the permission event.

_SetDepthCallbacks ( ) : void

Set callbacks for all DepthListener objects.

_SetEventCallbacks ( ) : void

Set callbacks for all TangoEventListener objects.

_SetMotionTrackingCallbacks ( TangoCoordinateFramePair framePairs ) : void

Set callbacks on all PoseListener objects.

_SetVideoOverlayCallbacks ( ) : void

Set callbacks for all VideoOverlayListener objects.

_SuspendTangoServices ( ) : void

Helper method that will suspend the tango services on App Suspend. Unlocks the tango config and disconnects the service.

_TangoConnect ( ) : void

Connect to the Tango Service.

_TangoDisconnect ( ) : void

Disconnect from the Tango Service.

_UnregisterOnAreaDescriptionEvent ( OnAreaDescriptionImportEventHandler import, OnAreaDescriptionExportEventHandler export ) : void

Unregister from the Tango event callbacks. See TangoApplication.Register for more details.

_UnregisterOnExperimentalTangoVideoOverlay ( OnExperimentalTangoImageAvailableEventHandler handler ) : void

Experimental API only, subject to change. Unregister from the Tango video overlay callbacks. See TangoApplication.Register for more details.

_UnregisterOnTangoCloudEvent ( OnTangoCloudEventAvailableEventHandler handler ) : void

Unregister from the Tango cloud event callbacks. See TangoApplication.Register for more details.

_UnregisterOnTangoConnect ( OnTangoConnectEventHandler handler ) : void

Unregister from the callback when connected to the Tango service. See TangoApplication.RegisterOnTangoConnect for more details.

_UnregisterOnTangoDepthEvent ( OnTangoDepthAvailableEventHandler handler ) : void

Unregister from the Tango depth callbacks. See TangoApplication.Register for more details.

_UnregisterOnTangoDisconnect ( OnTangoDisconnectEventHandler handler ) : void

Unregister from the callback when disconnected from the Tango service. See TangoApplication.RegisterOnTangoDisconnect for more details.

_UnregisterOnTangoEvent ( OnTangoEventAvailableEventHandler handler ) : void

Unregister from the Tango event callbacks. See TangoApplication.Register for more details.

_UnregisterOnTangoEventMultithreaded ( OnTangoEventAvailableEventHandler handler ) : void

Unregister from the Tango event callbacks. See TangoApplication.Register for more details.

_UnregisterOnTangoPoseEvent ( OnTangoPoseAvailableEventHandler handler ) : void

Unregister from the Tango pose callbacks. See TangoApplication.Register for more details.

_UnregisterOnTangoVideoOverlay ( OnTangoImageAvailableEventHandler handler ) : void

Unregister from the Tango video overlay callbacks. See TangoApplication.Register for more details.

_UnregisterPermissionsCallback ( PermissionsEvent permissionsEventHandler ) : void

Unregister from the permission callbacks. See TangoApplication.RegisterPermissionsCallback for more details.

_androidOnActivityResult ( int requestCode, int resultCode, AndroidJavaObject data ) : void

EventHandler for Android's on activity result.

_androidOnPause ( ) : void

Android on pause.

_androidOnResume ( ) : void

Android on resume.

_androidOnScreenOrientationChanged ( AndroidScreenRotation newOrientation ) : void

Delegate for the Android screen orientation changed.

Method Details

GetTangoServiceVersion() public static method

Get the Tango service version name.
public static GetTangoServiceVersion ( ) : string
return string

GetVideoOverlayTextureYUV() public method

Get the video overlay texture.
public GetVideoOverlayTextureYUV ( ) : YUVTexture
return YUVTexture

HasRequestedPermissions() public method

Check if all requested permissions have been granted.
public HasRequestedPermissions ( ) : bool
return bool

Register() public method

Register to get Tango callbacks. The object should derive from one of ITangoDepth, ITangoEvent, ITangoPos, ITangoVideoOverlay, or ITangoExperimentalTangoVideoOverlay. You will get callback during Update until you unregister.
public Register ( object tangoObject ) : void
tangoObject object Object to get Tango callbacks from.
return void

RequestPermissions() public method

Manual initialization step 1: Call this to request Tango permissions. To know the result of the permissions request, implement the interface ITangoLifecycle and register yourself before calling this. Once all permissions have been granted, you can call TangoApplication.Startup, optionally passing in the AreaDescription to load. You can get the list of AreaDescriptions once the appropriate permission is granted.
public RequestPermissions ( ) : void
return void

Set3DReconstructionEnabled() public method

Enable or disable the 3D reconstruction.
public Set3DReconstructionEnabled ( bool enabled ) : void
enabled bool If set to true enabled.
return void

SetDepthCameraRate() public method

Set the framerate of the depth camera. Disabling or reducing the framerate of the depth camera when it is running can save a significant amount of battery.
public SetDepthCameraRate ( TangoEnums rate ) : void
rate TangoEnums A special rate to set the depth camera to.
return void

SetDepthCameraRate() public method

Set the framerate of the depth camera. Disabling or reducing the framerate of the depth camera when it is running can save a significant amount of battery.
public SetDepthCameraRate ( int rate ) : void
rate int The rate in frames per second, for the depth camera to run at.
return void

Shutdown() public method

Disconnect from the Tango service. This is called automatically when the TangoApplication goes away. You only need to call this to disconnect from the Tango service before the TangoApplication goes away.
public Shutdown ( ) : void
return void

Startup() public method

Manual initalization step 2: Call this to connect to the Tango service. After connecting to the Tango service, you will get updates for Motion Tracking, Depth Sensing, and Area Learning. If you have a specific Area Description you want to localize too, pass that Area Description in here.
public Startup ( AreaDescription areaDescription ) : void
areaDescription AreaDescription If not null, the Area Description to localize to.
return void

Tango3DRClear() public method

Clear the 3D reconstruction data. The reconstruction will start fresh.
public Tango3DRClear ( ) : void
return void

Tango3DRExtractMeshSegment() public method

Extract a single grid cell's mesh.
public Tango3DRExtractMeshSegment ( Tango3DReconstruction gridIndex, Vector3 vertices, Vector3 normals, Color32 colors, int triangles, int &numVertices, int &numTriangles ) : Tango3DReconstruction.Status
gridIndex Tango3DReconstruction Grid index to extract.
vertices Vector3 Filled out with extracted vertices.
normals Vector3 Filled out with extracted normals.
colors UnityEngine.Color32 Filled out with extracted colors.
triangles int Filled out with extracted triangle indices.
numVertices int Filled out with the number of valid vertices.
numTriangles int Filled out with the number of valid triangles.
return Tango3DReconstruction.Status

Tango3DRExtractWholeMesh() public method

Extract a single mesh for the entire 3D reconstruction state.
public Tango3DRExtractWholeMesh ( Vector3 vertices, Vector3 normals, Color32 colors, int triangles, int &numVertices, int &numTriangles ) : Tango3DReconstruction.Status
vertices Vector3 Filled out with extracted vertices.
normals Vector3 Filled out with extracted normals.
colors UnityEngine.Color32 Filled out with extracted colors.
triangles int Filled out with extracted triangle indices.
numVertices int Filled out with the number of valid vertices.
numTriangles int Filled out with the number of valid triangles.
return Tango3DReconstruction.Status

Unregister() public method

Unregister from Tango callbacks. See TangoApplication.Register for more details.
public Unregister ( System tangoObject ) : void
tangoObject System Object to stop getting Tango callbacks from.
return void

Property Details

m_3drGenerateColor public_oe property

public bool m_3drGenerateColor
return bool

m_3drGenerateNormal public_oe property

public bool m_3drGenerateNormal
return bool

m_3drGenerateTexCoord public_oe property

public bool m_3drGenerateTexCoord
return bool

m_3drResolutionMeters public_oe property

public float m_3drResolutionMeters
return float

m_3drSpaceClearing public_oe property

public bool m_3drSpaceClearing
return bool

m_3drUseAreaDescriptionPose public_oe property

public bool m_3drUseAreaDescriptionPose
return bool

m_allowOutOfDateTangoAPI public_oe property

public bool m_allowOutOfDateTangoAPI
return bool

m_autoConnectToService public_oe property

public bool m_autoConnectToService
return bool

m_enable3DReconstruction public_oe property

public bool m_enable3DReconstruction
return bool

m_enableADFLoading public_oe property

public bool m_enableADFLoading
return bool

m_enableAreaLearning public_oe property

public bool m_enableAreaLearning
return bool

m_enableDepth public_oe property

public bool m_enableDepth
return bool

m_enableMotionTracking public_oe property

public bool m_enableMotionTracking
return bool

m_enableVideoOverlay public_oe property

public bool m_enableVideoOverlay
return bool

m_motionTrackingAutoReset public_oe property

public bool m_motionTrackingAutoReset
return bool

m_videoOverlayUseByteBufferMethod public_oe property

public bool m_videoOverlayUseByteBufferMethod
return bool