Skip to main content

ObjectDetectionConsumer

class · Singleton<ObjectDetectionConsumer> Unity component singleton
public class ObjectDetectionConsumer : Singleton<ObjectDetectionConsumer>

Namespace: AR51.Unity.SDK · Inherits: Singleton<ObjectDetectionConsumer> (MonoBehaviour) — access the live scene instance through ObjectDetectionConsumer.Instance.

Subscribes to the object-detection stream and spawns/updates GameObjects for detected markers and 6-DoF tracked objects. Each spawned GameObject carries a TrackedInstance component describing its current state. Positions are in Unity world space (meters), transformed through the configured Origin/anchor.

Units

Unity positions, radii, and lengths are in meters (world space); rotations are Quaternion; angles in degrees. Several fields below carry ⚠️ flags where the source unit or behavior needs confirmation — preserved verbatim.

Properties

All Inspector configuration fields are public (set in the Inspector or before Start). Read-only state is exposed as get-only properties.

PropertyTypeDefaultDescription
Display toggles
ShowMarkersbooltrueshow plain detection markers
ShowObjectsbooltrueshow 6-DoF tracked objects
ShowSkeletonMarkersboolfalseshow skeleton joint markers
ShowMarkerItemsbooltrueshow prefab marker-items in place of markers
Prefabs & materials
MarkerMaterialMaterialbase material for spawned markers / default cubes
PrefabsGameObject[]prefab pool for 6-DoF objects, matched by name to the server object Name
MarkerItemsMarkerItem[]per-marker-type prefab overrides
Marker sizing
MarkerSizefloat1global scale multiplier for markers (applied as MarkerSize * Radius)
BasketballRadiusfloat0.12fixed radius (m) for markers whose type contains "ball"
SkeletonMarkerSizefloat0.05scale (m) for skeleton markers
SkeletonMarkerColorColorColor.bluecolor applied to skeleton markers
Non-max suppression
EnableNMSWorkAroundboolfalsehide duplicate new markers near existing ones
NMSThresholdfloat0.01distance (m) under which a new marker is suppressed as a duplicate
Kalman filtering
EnabledFilteringboolfalseenable Kalman filtering of marker/object positions
ProcessNoisedouble2Kalman process-noise parameter
MeasurementNoisedouble0.005Kalman measurement-noise parameter
FutureDeltaTimedouble1.0/120.0prediction horizon (seconds)
UseDiscreteWhiteNoisebooltrueKalman noise-model toggle
UseAccelerationbooltrueinclude an acceleration term in the filter model
Smoothing (6-DoF objects)
SmoothRotationFactorfloat0.2[0..1] slerp weight for object rotation smoothing
SmoothPositionalFactorfloat0.2[0..1] lerp weight for object position smoothing
SmoothRotationAngleThresholdfloat12[0..90] degrees; above this, rotation snaps instead of smoothing
SmoothPositionalThresholdfloat0.03distance (m) above which position snaps instead of smoothing
Placement & misc
ModelLayerint0Unity layer assigned to spawned objects
OriginTransformorigin transform; spawned content aligns to its local-to-world
IsDebugboolfalsedebug flag
Read-only state
ModelLayerNamestringname of ModelLayer (get-only)
CameraIdsList<string>IDs of cameras contributing to the latest frame; refreshed each frame (get-only)
TrackedInstancesIEnumerable<TrackedInstance>all currently tracked instances (markers + objects) (get-only)
TrackedMarkersIEnumerable<TrackedInstance>currently tracked markers only (get-only)
TrackedObjectsIEnumerable<TrackedInstance>currently tracked 6-DoF objects only (get-only)

Method summary

Instance

MethodReturns
OnObjectDetectedvoidstream callback
AddTrackedObjectvoidpublic
RemoveTrackedObjectvoidpublic
ResetModelsvoidpublic

→ Full descriptions in Method details below.

Events

Standard C# event delegates — subscribe with +=.

EventSignatureFires when
OnObjectDetectionReceivedEventHandler<ObjectDetectionReply>once per received detection frame, at the start of processing, before GameObjects are updated

The ObjectDetectionReply argument (⚠️ declared elsewhere — AR51.GRPC.CVS transport type) carries the frame's markers, items, cameras, and capture time. Use it to observe raw detection frames as they arrive.

Method details

OnObjectDetected

methodpublic
public void OnObjectDetected(ObjectDetectionReply e);

Processes one detection frame: fires OnObjectDetectionReceived, then creates / updates / positions the marker and object GameObjects. Normally invoked internally from the stream; call it to feed a frame manually (e.g. playback). ⚠️ ObjectDetectionReply is a transport type declared elsewhere.

Parameters
eObjectDetectionReplythe detection frame to process

AddTrackedObject

methodpublic
public void AddTrackedObject(string name, TrackedInstance[] markers);

Registers a new trackable rigid object on the server, defined by the given marker instances (their color types and positions, recentered to their average). No-op with an error log if the object-detection client is unavailable.

Parameters
namestringname to register the new tracked object under
markersTrackedInstance[]the marker instances that define the rigid body (positions in meters, recentered to their average)
Exampleinferred
// Define a rigid object from the currently-tracked markers
var consumer = ObjectDetectionConsumer.Instance;
consumer.AddTrackedObject("Racket", consumer.TrackedMarkers.ToArray());

RemoveTrackedObject

methodpublic
public void RemoveTrackedObject(string name);

Unregisters a previously added tracked object by name.

Parameters
namestringthe name passed to AddTrackedObject

ResetModels

methodpublic
public void ResetModels();

Destroys all spawned marker / object GameObjects and clears internal tracking. Call to flush stale visuals (e.g. on scene reset or anchor change).

Inspector configuration

Drop the component on a GameObject (or reach it via ObjectDetectionConsumer.Instance). The fields under Properties are the Inspector knobs:

  • Display toggles (ShowMarkers, ShowObjects, ShowSkeletonMarkers, ShowMarkerItems) gate which detection categories are rendered.
  • Prefabs is the pool for 6-DoF objects, matched by name to the server object Name; MarkerItems override individual marker types with custom prefabs (see MarkerItem).
  • Origin anchors all spawned content — set it to the transform that represents your tracking space.
  • Filtering / smoothing fields tune the Kalman filter and per-object position/rotation smoothing.

InstanceType

enum
public enum InstanceType { Marker, Object }

Namespace: AR51.Unity.SDK. Nested in ObjectDetectionConsumer. Classifies a TrackedInstance.

ValueMeaning
Markera simple marker — sphere / 3-DoF point
Objecta full 6-DoF tracked object

MarkerItem

class · [Serializable]
[Serializable]
public class MarkerItem

Namespace: AR51.Unity.SDK. Nested in ObjectDetectionConsumer. Maps a marker type string to a prefab to spawn in place of the default marker. Edit entries in the Inspector via the MarkerItems array.

FieldTypeDefaultDescription
MarkerTypestringthe marker type / color label this entry matches
PrefabGameObjectprefab instantiated and tracked at the marker's position
Enabledbooltruewhether this marker-item is shown

TrackedMarkerExtensions

static class
public static class TrackedMarkerExtensions

Namespace: AR51.Unity.SDK. Static (non-MonoBehaviour) utility extension methods on TrackedMarker for interpreting marker IDs.

IsSkeletonMarker

methodstaticextension
public static bool IsSkeletonMarker(this TrackedMarker marker);

Tests whether the marker represents a skeleton joint (its Id contains "Skeleton"), letting callers distinguish skeleton-driven markers from free-standing detection markers.

Returnsbooltrue if the marker is a skeleton joint marker

TrySkeletonMarkerInfo

methodstaticextension
public static bool TrySkeletonMarkerInfo(this TrackedMarker marker, out string skeletonId, out string jointName);

Attempts to parse a skeleton marker's Id into a skeleton identifier and joint name. Returns false (with null outs) for non-skeleton markers. On success, skeletonId is normalized to a "Skeleton:Classic..." form and jointName is the joint label. ⚠️ needs confirmation: the exact skeletonId / jointName string formats depend on the server's marker-ID naming scheme.

Parameters
markerTrackedMarkerthe marker to parse
skeletonIdout stringon success, the normalized skeleton identifier; null otherwise
jointNameout stringon success, the joint label; null otherwise
Returnsbooltrue if the marker is a skeleton marker and was parsed

See also

  • TrackedInstance — the per-instance data model attached to each spawned marker / object GameObject
  • ObjectTransformConsumer — the parallel consumer for generic object transforms (position / rotation / scale)
  • ObjectTransform — a single object's pose fed to ObjectTransformConsumer
  • XRHeadsetTracker — streams XR-device transforms into ObjectTransformConsumer
  • ServiceManager — the connection entry-point that must be running before detections arrive
  • Class index — all Unity SDK types
Was this page helpful?