Open an image in the OA Viewer in Rust
Current source-owned tutorial. API availability differs by language.
Start the walkthrough · Jump to complete source
oa::Viewer::preview is the level-0 surface: one call opens a preconfigured application window with interactive pan, zoom, and per-channel inspection.
Run
cargo run -p sdk --release --example tu_viewer_image -- [image.jpg]
The path is optional and defaults to asset/image/coverMl.jpg through oa::Path::asset_rel.
1. One call, one window
The whole program is argument handling plus a single viewer call. preview owns the window, the presentation runtime, input handling, and the render loop:
1oa::Viewer::preview(path)2
The OpenCV parallel is exact: cv::imread plus cv::imshow plus cv::waitKey becomes Viewer::preview(path).
2. Controls
| Input | Action |
|---|---|
LMB / MMB / wheel | Pan and zoom |
+ / - | Zoom in / out |
0 / F | Fit to window |
9 | 100% zoom |
1–4 | R / G / B / A channel view |
5 | RGB composite |
B | Toggle dark / gradient background |
G | Toggle workspace grid |
Q / Esc | Quit |
What you built
An interactive GPU image viewer in one statement. The full source is sdk/rs/tutorials/vision/tu_viewer_image/tu_viewer_image.rs; the Python form is at walkthrough-python, and the headless render/sink version is the data augmentation walkthrough.
Example
1// ═══════════════════════════════════════════════════════════════════════════2// OA Tutorial: oa::Viewer · Universal GPU-Accelerated Image Viewer3// Level-0 API · oa::Viewer (preconfigured application class)4// ═══════════════════════════════════════════════════════════════════════════5//6// Demonstrates the unified viewer application with interactive image7// navigation.8//9// Parallel structure to OpenCV's image-display tutorial:10//11// OpenCV OA Rust12// ───────────────────────────── ──────────────────────────────────────13// cv::imread(path) let path = …;14// cv::imshow("name", mat) Viewer::preview(path)?;15// cv::waitKey(0)16//17// Controls (same as oa::Viewer):18// LMB / MMB / wheel · pan and zoom19// +/- · zoom in / out 0 / F · fit to window 9 · 100 %20// 1-4 · R/G/B/A channel 5 · RGB composite21// B · dark/gradient background; G · workspace grid22// Q / Esc · quit23//24// usage: cargo run --example tu_viewer_image -- [image.jpg]25//26// Donor: sdk/cpp/tutorials/vision/tuViewerImage.cpp27// ═══════════════════════════════════════════════════════════════════════════2829fn main() -> oa::Result<()> {30 let args: Vec<String> = std::env::args().collect();31 let default_path = oa::Path::asset_rel("image/coverMl.jpg");32 let path = args33 .get(1)34 .map(String::as_str)35 .unwrap_or_else(|| default_path.to_str().unwrap_or(""));3637 // ── OA_DOC_BEGIN: viewer-intro ──────────────────────────────────────────38 oa::Viewer::preview(path)39 // ── OA_DOC_END: viewer-intro ────────────────────────────────────────────40}41
Run Rust tutorials from the OA SDK checkout with cargo run --release --example <name>. Run Python with the environment containing the OA native extension. Consult each program's arguments and capability checks before running it.