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:
- For each detection, find the class index with the highest probability.
- Skip detections whose confidence is below confidenceThreshold.
- Extract the bounding box for each remaining detection (as left, top, right, bottom).
- Optionally include the tracking ID if available.
- 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
| confidenceThreshold | The minimum probability required for a detection to be kept. Detections below this threshold are discarded. |