Skip to main content

Object-detection consumer

ObjectDetectionConsumer subscribes to the AR 51 object-detection stream and spawns/updates Unity GameObjects for detected markers (simple 3-DoF points) and 6-DoF objects. It's a singleton component — access it via ObjectDetectionConsumer.Instance. Positions are Unity world-space, in meters.

Setup

Add an ObjectDetectionConsumer to your scene and configure it in the Inspector:

  • Prefabs — pool for 6-DoF objects, matched by name to the server object's Name.
  • MarkerItems — per-marker-type prefab overrides (MarkerTypePrefab).
  • Visibility: ShowMarkers, ShowObjects, ShowSkeletonMarkers, ShowMarkerItems.
  • Sizing: MarkerSize (global multiplier), SkeletonMarkerSize, BasketballRadius.
  • Smoothing (optional): EnabledFiltering (Kalman) with ProcessNoise / MeasurementNoise, plus SmoothPositionalFactor, SmoothPositionalThreshold (meters), SmoothRotationFactor, SmoothRotationAngleThreshold (degrees).

Reading detections

Subscribe to each frame, or read the current set any time:

using AR51.Unity.SDK;

var consumer = ObjectDetectionConsumer.Instance;

consumer.OnObjectDetectionReceived += (s, reply) => {
// fires once per detection frame, before GameObjects are updated
};

foreach (var inst in consumer.TrackedObjects) // 6-DoF objects (also: TrackedMarkers, TrackedInstances)
{
string id = inst.Id; // server object id
Vector3 pos = inst.Position; // world space, meters
Color color = inst.Color;
}

TrackedInstance (a component on each spawned GameObject) is the per-object data model:

MemberMeaning
Idserver marker/object id
TypeInstanceType.Marker or .Object
ColorName / Colorserver type/color label, and resolved Unity color
Positioncurrent world position (meters)
Radiusmarker radius ⚠️ (units appear to be meters / a scale × MarkerSize)
CaptureTimeserver capture timestamp (seconds)
IsSkeletonMarkertrue for skeleton-joint markers

Registering a trackable object

Define a new rigid object from a set of marker instances (their color types + positions, recentered to their average):

consumer.AddTrackedObject("my-prop", markerInstances); // TrackedInstance[]
consumer.RemoveTrackedObject("my-prop");
consumer.ResetModels(); // destroy all spawned markers/objects and clear tracking

(For the operator-side, point-and-click workflow, see Mocap Studio → Registering tracked objects.)

Generic object transforms

For objects whose pose is streamed directly (position/rotation/scale) rather than detected from markers, ObjectTransformConsumer maintains matching prefab GameObjects — feed it ObjectTransform records (Id, Type, Position, Rotation, Scale). XR headset poses arrive this way as type "XR".

Next

Was this page helpful?