Realm

Open an image in the OA Viewer in Rust

Current source-owned tutorial. API availability differs by language.

Rust · Python

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

InputAction
LMB / MMB / wheelPan and zoom
+ / -Zoom in / out
0 / FFit to window
9100% zoom
1–4R / G / B / A channel view
5RGB composite
BToggle dark / gradient background
GToggle workspace grid
Q / EscQuit

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 Viewer
3// Level-0 API · oa::Viewer (preconfigured application class)
4// ═══════════════════════════════════════════════════════════════════════════
5//
6// Demonstrates the unified viewer application with interactive image
7// navigation.
8//
9// Parallel structure to OpenCV's image-display tutorial:
10//
11// OpenCV OA Rust
12// ───────────────────────────── ──────────────────────────────────────
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 zoom
19// +/- · zoom in / out 0 / F · fit to window 9 · 100 %
20// 1-4 · R/G/B/A channel 5 · RGB composite
21// B · dark/gradient background; G · workspace grid
22// Q / Esc · quit
23//
24// usage: cargo run --example tu_viewer_image -- [image.jpg]
25//
26// Donor: sdk/cpp/tutorials/vision/tuViewerImage.cpp
27// ═══════════════════════════════════════════════════════════════════════════
28
29fn 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 = args
33 .get(1)
34 .map(String::as_str)
35 .unwrap_or_else(|| default_path.to_str().unwrap_or(""));
36
37 // ── 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.