AimForge DOCS
Pricing Login
docs / api / detection

Detection

The detection object exposes everything the runtime knows about the current target. It's repopulated every frame.

Position & size

Property Type Description
detection.x float Center X of bounding box (pixels).
detection.y float Center Y of bounding box (pixels).
detection.w float Width of bounding box (pixels).
detection.h float Height of bounding box (pixels).

Confidence & identity

Property Type Description
detection.confidence float Detection confidence (0.0–1.0).
detection.classId int Model class index.
detection.modelId int Source model ID when multiple models are stacked.
detection.targetId int Persistent ID across frames (for tracking).
detection.targetAge float Frames the target has been continuously tracked.
detection.shouldIgnore int 1 if filtered out by ignoreColour() or similar rules.

Motion

Property Type Description
detection.velocityX float Horizontal velocity (pixels / frame).
detection.velocityY float Vertical velocity (pixels / frame).
detection.speed float Magnitude of velocity vector.
detection.maxSpeed float Peak observed speed.
detection.directionX float Normalized X direction.
detection.directionY float Normalized Y direction.

Model frame metadata

Property Type Description
detection.modelInputW float Model's input tensor width.
detection.modelInputH float Model's input tensor height.
detection.modelActiveW float Active inference region width.
detection.modelActiveH float Active inference region height.

Keypoints (pose models)

detection.keypoints is an array of 17 keypoint objects when running a YOLO-Pose model. Each has .x, .y, and .confidence. Index into the array using the KP constants.

head = detection.keypoints[KP.NOSE];
if (head.confidence > 0.5) {
  drawCircle(head.x, head.y, 4, "red", 2);
}

Example

A simple "aim at the closest detection if confident enough" script:

if (confidence > 0.6 && dtDetectionTime < 100) {
  x = detection.x - center_x;
  y = detection.y - center_y;
  return (x, y);
}
return (0, 0);