|
| 1 | +# zed-sdk |
| 2 | + |
| 3 | +Safe Rust bindings for the Stereolabs ZED C API. |
| 4 | + |
| 5 | +This crate wraps the low-level `sl_zed_c` interface in a typed Rust API for: |
| 6 | + |
| 7 | +- opening a camera, SVO file, stream, or GMSL source |
| 8 | +- grabbing image and depth frames into typed matrices |
| 9 | +- reading calibration, camera, and sensor metadata |
| 10 | +- keeping an escape hatch to the raw FFI through `zed_sdk::sys` |
| 11 | + |
| 12 | +## Requirements |
| 13 | + |
| 14 | +- Linux |
| 15 | +- the proprietary ZED SDK installed under `/usr/local/zed` or `/opt/zed-sdk` |
| 16 | +- a working CUDA/ZED runtime suitable for your camera and chosen depth mode |
| 17 | + |
| 18 | +The sibling `zed-sdk-sys` crate links against an installed `libsl_zed_c` if it is already present. |
| 19 | +If that wrapper is not installed yet, the build script can compile the vendored `zed-c-api` wrapper with CMake instead. |
| 20 | + |
| 21 | +If you need the vendored wrapper path, initialize the submodule from the repository root: |
| 22 | + |
| 23 | +```bash |
| 24 | +git submodule update --init --recursive components/libs/zed_sdk_sys/vendor/zed-c-api |
| 25 | +``` |
| 26 | + |
| 27 | +## Basic Use |
| 28 | + |
| 29 | +```rust,ignore |
| 30 | +use zed_sdk::{Camera, Mat, OpenOptions, ResolutionPreset, Rgba8, RuntimeParameters}; |
| 31 | +
|
| 32 | +let options = OpenOptions::default() |
| 33 | + .camera_device_id(0) |
| 34 | + .resolution(ResolutionPreset::Hd720) |
| 35 | + .fps(30); |
| 36 | +
|
| 37 | +let mut camera = Camera::open(options)?; |
| 38 | +let resolution = camera.resolution()?; |
| 39 | +let runtime = RuntimeParameters::default(); |
| 40 | +let mut left = Mat::<Rgba8>::new_cpu(resolution)?; |
| 41 | +
|
| 42 | +camera.grab(&runtime)?; |
| 43 | +camera.retrieve_left(&mut left)?; |
| 44 | +
|
| 45 | +let view = left.view()?; |
| 46 | +println!("captured {}x{}", view.width(), view.height()); |
| 47 | +# Ok::<(), zed_sdk::Error>(()) |
| 48 | +``` |
| 49 | + |
| 50 | +`Mat<T>` keeps the element type explicit, so color, depth, and point-cloud buffers stay aligned with the SDK view or measure you request. |
| 51 | + |
| 52 | +## Running The Demo |
| 53 | + |
| 54 | +The crate includes `zed_viz_demo`, an `egui` viewer that overlays clipped depth on the left image feed. |
| 55 | + |
| 56 | +From this directory: |
| 57 | + |
| 58 | +```bash |
| 59 | +cargo run --release --bin zed_viz_demo -- PERFORMANCE |
| 60 | +``` |
| 61 | + |
| 62 | +Supported depth mode arguments are: |
| 63 | + |
| 64 | +- `NONE` |
| 65 | +- `PERFORMANCE` |
| 66 | +- `QUALITY` |
| 67 | +- `ULTRA` |
| 68 | +- `NEURAL_LIGHT` |
| 69 | +- `NEURAL` |
| 70 | +- `NEURAL_PLUS` |
| 71 | + |
| 72 | +Convenience targets are also available: |
| 73 | + |
| 74 | +```bash |
| 75 | +just performance |
| 76 | +just neural-light |
| 77 | +just neural |
| 78 | +``` |
| 79 | + |
| 80 | +`just` defaults to `neural-light`. |
| 81 | + |
| 82 | +## Raw FFI Access |
| 83 | + |
| 84 | +If you need an SDK entry point that is not wrapped yet, use `zed_sdk::sys` directly and keep the safe layer for everything else. |
0 commit comments