On this page
on_start
Runs once when the script starts.
Syntax
Atlas Script
event on_start() { }Return value
See the remarks for the returned value and runtime behavior.
Remarks
Runs once when the script starts. Use it to configure vision tools, model paths, and starting values.
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));
}