Realm

Image viewer

Source-owned programs from the current OA SDK. Rust and Python examples follow their respective public APIs.

Rust · Python

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 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.