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. |
calibrationsFile |
TextAsset |
Camera calibration data (JSON). If not assigned, loads default from Resources. | |
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 |
followArWorldJumps |
bool |
true | When the AR session moves its world, the AR camera jumps farther in one frame than a hand can move a phone (more than 25 centimeters and faster than 5 meters per second, or more than 45 degrees and faster than 900 degrees per second). With this on, every tracked body is carried into the new world, so it keeps its place relative to the camera. With this off, a body can lose the object after such a jump. The inspector shows it as Follow AR World Jumps, under the pose fusion row, and only while pose fusion is on. |
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 the manager captures the image itself and tracks from its own tracking loop (Native, RealSense or Sequence modes). Injected mode is the other case, where a camera feeder supplies the frames. |
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 | |
FollowArWorldJumps |
bool |
get/set | Whether every tracked body is carried into the new world when the AR session moves its world. The AR camera then jumps farther in one step than a hand can move a phone, which is more than 25 centimeters and faster than 5 meters per second, or more than 45 degrees and faster than 900 degrees per second. With this on, each body keeps its place relative to the camera across the jump. With this off, the bodies stay at the poses they held in the old world, and a body can lose the object. It is on by default, it acts only under AR pose fusion, and the tracker reads it on every step, so a change applies at once. |
LicenseTier |
LicenseTier |
get | Current license tier (None = no license loaded). |
LicenseStatus |
LicenseStatus |
get | Current license validation status. |
IsLicenseFrozen |
bool |
get | Deprecated. Was used for Free tier 60s limit. |
FreeSecondsRemaining |
float |
get | Deprecated. Was used for Free tier countdown. |
MachineId |
string |
get | Machine ID used for Commercial 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 |
The depth frames of the tracker are forwarded to Unity for recording, so OnDepthFrameFed fires for each of them. Call DisableDepthForwarding() when done to avoid unnecessary overhead. |
DisableDepthForwarding() |
void |
The depth frames are no longer forwarded to Unity, so a tracking step skips the copy of the depth buffer (about 800 KB per frame). |
GetScreenRotation() |
int |
It returns the current screen rotation mode, from 0 to 3, for use with the FeedFrame methods. A value of 0 is landscape left, 1 is portrait, 2 is landscape right and 3 is portrait upside down. |
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() |
bool |
Called before native tracking step on all registered bodies. Returns whether the step may run. |
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. |