v0.2.0: pure camera source on dora 1.0 #18
@@ -9,12 +9,14 @@ A dora-rs C++ node that interfaces with ZED stereo cameras. On each tick it grab
|
||||
## Build
|
||||
|
||||
```bash
|
||||
mkdir -p build && cd build && cmake .. && make install
|
||||
scripts/build.sh
|
||||
```
|
||||
|
||||
The binary is installed to `bin/dora_zed` relative to the repo root.
|
||||
The binary is installed to `bin/dora_zed` relative to the repo root. The script is also
|
||||
the dataflow's `build:` command: dora 1.0 executes build commands directly rather than
|
||||
through a shell, so `cd`, `&&` and command substitution do not work there.
|
||||
|
||||
**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).
|
||||
**Requirements:** dora 1.0+ (verified with `dora-cli 1.0.1`), 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.
|
||||
|
||||
@@ -40,7 +42,8 @@ Camera and detection behavior is configured entirely through environment variabl
|
||||
- **`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 with `ZED_ONNX_OUTPUT_FORMAT`. Labels loaded from `ZED_ONNX_LABELS` or `ZED_ONNX_LABELS_FILE`.
|
||||
- **`src/main.cc`** — Dora event loop. Selects engine via `ZED_ENGINE` env var (`yolo_onnx`/`onnx` or `native`), holds a `std::unique_ptr<engines::Engine>`. Parses `ZED_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): calls `camera.grab()` and `detector->detect()`, then sends `image_bgr`, `point_cloud`, `camera_info`, and `objects` outputs. Point cloud output varies by mode: `FULL` sends the raw `sl::Mat` pointer (no copy); `HALF` downsamples by 2 in each dimension; `ROI` emits 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. Produces `dora_node_api_cxx` library and the `node_bridge.cc` glue.
|
||||
- **`dataflow.yml`** — Example dora dataflow definition using the `git:` source format.
|
||||
- **`scripts/build.sh`** — Configure/compile/install in one shell-free-callable step. Referenced by `dataflow.yml`, the `Dockerfile` and the README.
|
||||
- **`dataflow.yml`** — Example dora dataflow definition using the `git:` source format, pinned with `tag:` — dora 1.0 pins a source with the mutually exclusive `tag:`, `rev:` or `branch:`.
|
||||
- **`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`. Sets `NVIDIA_DRIVER_CAPABILITIES=compute,utility,video` — the `video` capability is what makes the container runtime mount NVDEC/NVENC, which `libsl_zed.so` links against. ONNX Runtime's CMake package files are relocated to `/usr/local/lib/cmake` because Ubuntu's multiarch CMake does not search `lib64`. Rust lives at `/usr/local/{rustup,cargo}` rather than `/root` so 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`). Exercises `YoloOnnx` with an image (default `test/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.
|
||||
|
||||
@@ -4,6 +4,12 @@ project(dora_zed VERSION 0.1.0 LANGUAGES C CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_FLAGS "-fPIC")
|
||||
|
||||
# DoraTargets.cmake picks the cargo profile from this, so an unset build type
|
||||
# would link debug dora bindings into an otherwise unoptimized binary.
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
|
||||
include(DoraTargets.cmake)
|
||||
|
||||
set(ZED_DIR "/usr/local/zed" CACHE PATH "Path to the ZED SDK")
|
||||
|
||||
+1
-1
@@ -72,4 +72,4 @@ RUN curl -fSL -o /tmp/ort.tgz \
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
|
||||
|
||||
WORKDIR /src
|
||||
CMD ["bash", "-lc", "mkdir -p build && cd build && cmake .. && make -j$(nproc) install"]
|
||||
CMD ["scripts/build.sh"]
|
||||
|
||||
@@ -10,8 +10,8 @@ Add to your dataflow:
|
||||
nodes:
|
||||
- id: zed-camera
|
||||
git: ssh://git@gitea.liria.cl:5001/liria/dora-zed.git
|
||||
git_checkout: v0.1.0
|
||||
build: mkdir -p build && cd build && cmake .. && make install
|
||||
tag: v0.2.0
|
||||
build: scripts/build.sh
|
||||
path: bin/dora_zed
|
||||
inputs:
|
||||
tick: dora/timer/millis/100
|
||||
@@ -28,6 +28,7 @@ See [`dataflow.yml`](dataflow.yml) for a complete runnable example with a camera
|
||||
|
||||
| Dependency | Version | Notes |
|
||||
|---|---|---|
|
||||
| [dora-rs](https://github.com/dora-rs/dora) | 1.0+ | Verified against `dora-cli 1.0.1`; the C++ bindings are built from source at configure time |
|
||||
| [CMake](https://cmake.org/download/) | 3.21+ | |
|
||||
| [ZED SDK](https://www.stereolabs.com/developers/release) | 5.x | Bundles OpenCV; default path `/usr/local/zed` |
|
||||
| [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) | — | Required by ZED SDK |
|
||||
@@ -51,11 +52,17 @@ See [`dataflow.yml`](dataflow.yml) for a complete runnable example with a camera
|
||||
```bash
|
||||
git clone ssh://git@gitea.liria.cl:5001/liria/dora-zed.git
|
||||
cd dora-zed
|
||||
mkdir -p build && cd build && cmake .. && make install
|
||||
scripts/build.sh
|
||||
```
|
||||
|
||||
Binary installed to `bin/dora_zed`.
|
||||
|
||||
`scripts/build.sh` is also the `build:` command in the dataflow. dora 1.0 runs build
|
||||
commands directly rather than through a shell, so `cd`, `&&` and command substitution are
|
||||
not available there; keeping the sequence in one script is what makes the dataflow build
|
||||
work. It configures a `Release` build, which is also what links the optimized dora
|
||||
bindings.
|
||||
|
||||
### Containerized build
|
||||
|
||||
[`Dockerfile`](Dockerfile) provides the full toolchain — CUDA, ZED SDK, ONNX Runtime and Rust — on Ubuntu 24.04, the newest release Stereolabs ships a ZED SDK for. No camera is needed.
|
||||
@@ -66,6 +73,8 @@ docker run --rm --gpus all --user "$(id -u):$(id -g)" \
|
||||
-v "$PWD:/src" -v dora-zed-cargo:/usr/local/cargo/registry dora-zed-build
|
||||
```
|
||||
|
||||
The container runs the same `scripts/build.sh`.
|
||||
|
||||
The first run clones dora-rs and compiles it with Cargo; the named volume keeps that cache across runs.
|
||||
`--user` keeps `build/` and `bin/` owned by you rather than root.
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
nodes:
|
||||
- id: zed-camera
|
||||
git: ssh://git@gitea.liria.cl:5001/liria/dora-zed.git
|
||||
git_checkout: v0.1.0
|
||||
build: mkdir -p build && cd build && cmake .. && make install
|
||||
tag: v0.2.0
|
||||
build: scripts/build.sh
|
||||
path: bin/dora_zed
|
||||
inputs:
|
||||
tick: dora/timer/millis/100
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Configure, compile and install the node into bin/.
|
||||
#
|
||||
# dora 1.0 runs a node's `build:` command directly rather than through a shell,
|
||||
# so `cd`, `&&` and command substitution are not available there. The whole
|
||||
# sequence lives here instead, and the dataflow only invokes this script.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
BUILD_DIR="${REPO_DIR}/build"
|
||||
|
||||
cmake -S "$REPO_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build "$BUILD_DIR" --target install --parallel "$(nproc)"
|
||||
Reference in New Issue
Block a user