Skip to content

XRTrackerManager

Inherits from: MonoBehaviour

Serialized Fields

Field Type Default Description
imageSource ImageSource ImageSource.Native Native: Use built-in webcam capture. Injected: Receive frames from external source (AR Foundation, etc.)
sequenceDirectory string Folder with sequence.json and recorded frames. Falls back to latest subfolder if needed.
realSenseColorResolution RealSenseColorResolution RealSenseColorResolution.Resolution_1920x1080_30fps RealSense color camera resolution. Higher = more detail, lower FPS.
realSenseDepthResolution RealSenseDepthResolution RealSenseDepthResolution.Resolution_1280x720_30fps RealSense depth camera resolution. Higher = more detail, lower FPS.
calibrationsFileName string "camera-calibrations.json" JSON file containing camera calibration data. Located in StreamingAssets.
autoSelectCameraName string "" Automatically select and initialize a camera on start. Leave empty to disable.
autoSelectFallbackToFirst bool true If auto-select camera name not found, fall back to first available camera.
mainCamera Camera Main camera used for tracking. If not set, Camera.main will be used.
useARPoseFusion bool true Use AR Foundation's world tracking to stabilize pose when tracking quality drops

Properties

Property Type Access Description
Instance XRTrackerManager get
AvailableCameras FTCameraDevice[] get
SelectedCameraIndex int get
SelectedCamera FTCameraDevice? get
IsInitialized bool get
IsTrackingReady bool get
UsesNativeCapture bool get True if using native capture (Native or RealSense modes). These modes use TrackingCoroutine and FT_ProcessImageCallback.
RequiresCalibrationFile bool get True if calibration file is required (only Native/webcam mode). RealSense and Injected modes get intrinsics from SDK/AR Foundation.
HasDepthCamera bool get True if depth camera is available. Query from native after initialization.
CropFactorX float get
CropFactorY float get
CameraTransform Transform get
ImageWidth int get Current tracking image width in pixels. Returns 0 if not initialized.
ImageHeight int get Current tracking image height in pixels. Returns 0 if not initialized.
IsTrackingInProgress bool get Returns true if async tracking is currently in progress (injected mode only). Use this to know when it's safe to call FeedFrameAsync again.
TrackedBodies IReadOnlyList<TrackedBody> get All registered TrackedBodies. Use this to iterate over tracked objects.
CurrentTexture Texture get/set
CachedFu float get Cached normalized focal length U from last frame feed.
CachedFv float get Cached normalized focal length V from last frame feed.
CachedPpu float get Cached normalized principal point U from last frame feed.
CachedPpv float get Cached normalized principal point V from last frame feed.
UseARPoseFusion bool get/set
LicenseTier LicenseTier get Current license tier (None = no license loaded, Free = 60s limit).
LicenseStatus LicenseStatus get Current license validation status.
IsLicenseFrozen bool get True if Free tier 60s limit has been reached.
FreeSecondsRemaining float get Seconds remaining for Free tier (60s). Returns -1 for non-Free tiers.
MachineId string get Machine ID used for Pro license node-locking.

Methods

Method Returns Description
SetLicense(string licenseJson) LicenseStatus Load a license from a JSON string at runtime. Returns the resulting LicenseStatus.
RefreshLicenseState() void Refresh cached license state from native side. Call if you need up-to-date frozen state.
FeedDepthFrame(IntPtr depthData, int width, int height) void Feed a depth frame to the injected depth camera and fire OnDepthFrameFed.
EnableDepthForwarding() void Enable depth frame forwarding from C++ to Unity (for recording). Registers the native depth callback so FT_TrackStep queues depth frames. Call DisableDepthForwarding() when done to avoid unnecessary overhead.
DisableDepthForwarding() void Disable depth frame forwarding. Clears the native depth callback so FT_TrackStep skips the ~800KB/frame depth buffer copy.
GetScreenRotation() int Get the current screen rotation mode for use with FeedFrame methods. Returns: Screen rotation value (0-3) for FT_FeedFrame
EnumerateCameras() void
FindCameraByName(string cameraName) int Find camera index by name (case-insensitive exact match). cameraName: Camera name to search for Returns: Camera index if found, -1 otherwise
SelectCameraAsync(int cameraIndex) Task
PauseTracking() void
ResumeTracking() void
StartDetection() void
StartTracking() void
RegisterTrackedBody(TrackedBody body) void Register a TrackedBody for quality-based state management. Called automatically by TrackedBody when registered.
UnregisterTrackedBody(TrackedBody body) void Unregister a TrackedBody. Called automatically by TrackedBody when unregistered.
AcquireNativeLockAsync() Task Acquires the native access lock asynchronously. Call ReleaseNativeLock when done. Use this before calling native registration/unregistration functions to ensure no tracking is in progress.
ReleaseNativeLock() void Releases the native access lock. Must be called after AcquireNativeLockAsync.
BeforeTrackingStep() void Called before native tracking step on all registered bodies.
AfterTrackingStep() void Called after native tracking step on all registered bodies.
InitializeInjectedAsync(FTCameraIntrinsics intrinsics) Task<bool> Initialize tracker for Injected mode (AR Foundation). Call FeedFrame() to provide camera frames, then TrackStep() to run tracking.
InitializeSequenceAsync(string sequenceDirectory) Task Public API for initializing sequence mode. Sets the image source, sequence directory, and calls the internal initialization.
InitializeRealSenseAsync() Task<bool> Initialize tracker for RealSense mode (native color + depth capture). RealSense SDK provides intrinsics automatically.
InitializeWithCameraAsync(string cameraName, CalibrationIntrinsics intrinsics, CalibrationIntrinsics intrinsicsDist = null) Task Initialize with a camera by name, providing intrinsics directly. Use this for manual setup without relying on calibration files. cameraName: Camera device name to find and use intrinsics: Undistorted camera intrinsics intrinsicsDist: Distorted camera intrinsics (optional, defaults to intrinsics)
PostImage(Texture texture) void

Events

Event Type Description
OnTrackerInitialized Action
OnTrackerShutdown Action
OnCameraSelected Action<FTCameraDevice>
OnImage Action<Texture>
OnCropFactorsChanged Action
OnBeforeTrackingStep Action Called before each tracking step begins. Use this to prepare data before native tracking runs.
OnAfterTrackingStep Action Called after each tracking step completes. Use this to apply poses immediately after native tracking (best timing for non-SLAM).
OnTrackingPaused Action Called when tracking is paused via PauseTracking().
OnTrackingResumed Action Called when tracking is resumed via ResumeTracking().
OnFrameFed Action<IntPtr, int, int, float, float, float, float, int> Called after a frame is fed to the native tracker via FeedFrame/FeedFrameAsync. Parameters: rgbDataPtr, width, height, fuNorm, fvNorm, ppuNorm, ppvNorm, screenRotation. Use this to intercept frames for recording.
OnDepthFrameFed Action<IntPtr, int, int, float> Called when a depth frame is available. Fired by FeedDepthFrame (injected) or HandleDepthImageCallback (RealSense). Parameters: depthDataPtr, width, height, depthScale. Use this to intercept depth frames for recording.