Skip to main content

ARDK for Android/com.nianticlabs.ardk.objectdetection/toDetectedObjects

toDetectedObjects

[androidJvm]
fun ObjectDetectionResult.toDetectedObjects(confidenceThreshold: Float = 0.4f): List<DetectedObject>

Converts this ObjectDetectionResult into a list of strongly typed DetectedObject instances.

This method reads the raw buffers returned from the native object-detection inference (bounding boxes, per-class probabilities, and optional tracking IDs) and constructs high-level objects that are easier to work with in Kotlin.

Processing steps:​

  1. For each detection, find the class index with the highest probability.
  2. Skip detections whose confidence is below confidenceThreshold.
  3. Extract the bounding box for each remaining detection (as left, top, right, bottom).
  4. Optionally include the tracking ID if available.
  5. Return all valid detections as a list of DetectedObjects.

Return​

A list of DetectedObjects representing valid detections. Returns an empty list if no detections are available or if required buffers are null.

Parameters​

androidJvm

confidenceThresholdThe minimum probability required for a detection to be kept. Detections below this threshold are discarded.