On this page
vision.model
Configures an ONNX Runtime detector from a source model returned by models.set and returns a configured live model value.
Syntax
Atlas Script
vision.model(model, labels?, roi?, threshold?, enabled?, backend?)Parameters
model- Source model returned by models.set. Its model file and metadata configure the requested ONNX detector.
labelsOptional- Optional class-label source: one label, an array of labels, or null when labels are not supplied.
roiOptional- Optional region of interest: a four-value [x, y, width, height] array. Pass null when the method accepts a full-frame scan.
thresholdOptional- Detection or matching threshold. Higher values require a stronger match.
enabledOptional- Optional boolean that turns this configured tool on or off. Use true to process it and false to keep its configuration without running it.
backendOptional- Optional inference backend selection. Use the documented vision backend constant for the installed Atlas build.
Return value
Returns model.
Remarks
Configures an ONNX Runtime detector from a source model returned by models.set and returns a configured live model value. Only model is required. labels may be one string, an array, or null; roi defaults to null for the full frame, threshold to 0.5, enabled to true, and backend to vision.auto (vision.gpu and vision.directml both select DirectML). Read/set enabled, overlay, roi, threshold; read labels, results, count, target. Keep the separate source model for name/path reads.
Examples
Configure an ONNX detector.atlas
model objectSource = models.set("models/object_detector.onnx");
model objectDetector;
const scanRadius = 0.18;
const scanRoi = [0.5 - scanRadius, 0.5 - scanRadius, scanRadius * 2, scanRadius * 2];
event on_start() {
objectDetector = vision.model(objectSource, "object", scanRoi, 0.50, true, vision.auto);
}
event on_frame() {
ui.circle(0.5, 0.5, scanRadius, rgb.cyan, 2, false);
target detectedObject = objectDetector.target;
if (detectedObject == null) {
ui.status("No object detected");
return;
}
ui.rect(detectedObject.box.x, detectedObject.box.y, detectedObject.box.width, detectedObject.box.height, rgb.lime, 3, false);
ui.status(string.format("Object {}", detectedObject.confidence));
}