Dockerfile provisions CUDA 12.8, ZED SDK 5.2, ONNX Runtime and Rust on Ubuntu 24.04, the newest release Stereolabs ships a ZED SDK for, so the node can be compiled and the build verified without installing the SDK stack on the host. The compile needs --gpus all: libsl_zed.so links against the CUDA driver API, NVDEC and NVENC, which ship with the display driver rather than the CUDA toolkit and so exist in no image. The container runtime mounts them from the host, and only includes NVDEC/NVENC when the video capability is requested. Runs as the invoking user so build/ and bin/ are not left root-owned, which needs the toolchain outside /root and the ZED SDK directory readable to an arbitrary uid.
5.8 KiB
AGENTS.md
This file provides guidance to AI coding assistants when working with code in this repository.
What this is
A dora-rs C++ node that interfaces with ZED stereo cameras. On each tick it grabs a frame, runs object detection, and publishes four outputs over the dora dataflow: a BGR image, an XYZRGBA point cloud, camera intrinsics, and detected objects with 3D positions. Camera management lives in src/zed/, detection engines in src/engines/, and the dora event loop in src/main.cc.
Build
mkdir -p build && cd build && cmake .. && make install
The binary is installed to bin/dora_zed relative to the repo root.
Requirements: CMake 3.21+, ZED SDK 5.x (at /usr/local/zed), CUDA Toolkit, ONNX Runtime 1.20+ (system install), Rust stable toolchain (for dora-rs C++ bindings).
The first build clones dora-rs from GitHub and compiles dora-node-api-cxx via Cargo. This takes a while. Subsequent builds are incremental. If DORA_ROOT_DIR is set to a local dora checkout, it builds against that instead.
For a build without installing the SDK stack on the host, see the Dockerfile (Ubuntu 24.04 — the newest release with a ZED SDK; there is no Stereolabs build for 26.04). Run the compile with --gpus all.
Run
dora up
dora start dataflow.yml
Camera and detection behavior is configured entirely through environment variables (see README.md for the full list: ZED_RESOLUTION, ZED_FPS, ZED_DEPTH_MODE, ZED_DETECTION_MODEL, etc.).
Architecture
src/util/env.h— Shared inline env-variable parsing helpers (get_env_int,get_env_str,get_env_bool,get_env_float).src/zed/camera.h—zed::Config,zed::Calibration, andzed::Cameraclass. Camera wraps the ZED SDK lifecycle: open (with retry loop), warmup, grab (image + point cloud), calibration, and close. Exposeshandle()for engine access.src/zed/camera.cc— Implementation. SDK enum parsers live in an anonymous namespace.src/engines/engine.h—engines::DetectedObjectstruct andengines::Engineabstract base class (enable,detect,objects,label_names).src/engines/zed_native.h/cc—engines::ZedNative: wraps ZED SDK's TensorRT-optimized object detection module.src/engines/yolo_helpers.h— Header-only shared helpers used by the ONNX engine:RawDetection,nms(),letterbox(),fuse_bbox(),backproject(). Lives inengines::detailnamespace.src/engines/yolo_onnx.h/cc—engines::YoloOnnx/YoloOnnxConfig: closed-vocabulary detection for any single-input YOLO ONNX model (YOLOv8, YOLOv11, YOLOv5, etc.). Auto-detects output layout (NC_FIRST/NC_LAST/NC_LAST_OBJ) from tensor shape; override withZED_ONNX_OUTPUT_FORMAT. Labels loaded fromZED_ONNX_LABELSorZED_ONNX_LABELS_FILE.src/main.cc— Dora event loop. Selects engine viaZED_ENGINEenv var (yolo_onnx/onnxornative), holds astd::unique_ptr<engines::Engine>. ParsesZED_PC_MODE(FULL/HALF/ROI) once before the loop. On any input event (intended to be driven by a tick timer; the id is not inspected): callscamera.grab()anddetector->detect(), then sendsimage_bgr,point_cloud,camera_info, andobjectsoutputs. Point cloud output varies by mode:FULLsends the rawsl::Matpointer (no copy);HALFdownsamples by 2 in each dimension;ROIemits only valid points within detected bounding boxes as a flat[N, 4]array. Handles reconnection on grab failure.DoraTargets.cmake— Handles building or fetching dora-rs and generating the CXX bridge files. Two paths: local (DORA_ROOT_DIR) or git clone. Producesdora_node_api_cxxlibrary and thenode_bridge.ccglue.dataflow.yml— Example dora dataflow definition using thegit:source format.Dockerfile— Ubuntu 24.04 x86-64 build environment (CUDA 12.8, ZED SDK 5.2, ONNX Runtime, Rust). No ARM64/Jetson image; build natively there. No camera needed; run the compile with--gpus all. SetsNVIDIA_DRIVER_CAPABILITIES=compute,utility,video— thevideocapability is what makes the container runtime mount NVDEC/NVENC, whichlibsl_zed.solinks against. ONNX Runtime's CMake package files are relocated to/usr/local/lib/cmakebecause Ubuntu's multiarch CMake does not searchlib64. Rust lives at/usr/local/{rustup,cargo}rather than/rootso the build can run as the invoking user.docker build -t dora-zed-build . && docker run --rm --gpus all --user "$(id -u):$(id -g)" -v "$PWD:/src" -v dora-zed-cargo:/usr/local/cargo/registry dora-zed-build.scripts/export_yolo.py— PEP 723 uv script. Exports a standard YOLOv11 model to ONNX for closed-vocabulary detection. Run:uv run scripts/export_yolo.py --model n --output-dir models/.src/test_yolo_onnx.cc— Standalone C++ test binary (bin/test_yolo_onnx). ExercisesYoloOnnxwith an image (defaulttest/assets/yolo.png). No dora and no live camera required. Uses the same env vars as the main binary. Saves an annotated result image alongside the input.
Key APIs
- dora C++ API (
<dora-node-api.h>):init_dora_node(),dora_node.events->next(),event_type(),send_output_with_metadata(),new_metadata(). - ZED SDK (
<sl/Camera.hpp>):sl::Camera,sl::InitParameters,sl::RuntimeParameters,sl::Mat,sl::ObjectDetectionParameters,sl::Objects. - ONNX Runtime (
<onnxruntime_cxx_api.h>):Ort::Env,Ort::Session,Ort::SessionOptions,Ort::Value. Used by theyolo_onnxengine. - Output data is sent as raw byte slices (
rust::Slice<const uint8_t>) with typed metadata (shape, dtype, encoding).
Tools
- Issue tracker: Gitea. Use the Gitea MCP tools (
mcp__gitea__*) to read and manage issues, pull requests, and other repository operations.
Rules
- Do not mention AI tools in commit messages or documentation.