Image operations
Source-owned programs from the current OA SDK. Rust and Python examples follow their respective public APIs.
Rust · Python
The former six-view augmentation tutorial has not been ported. These current programs demonstrate Rust headless image rendering and Python image operations; they are separate workflows.
Example
1use oa::render::{blit, clear, save_texture_file, texture_from_file};2use oa::{Engine, Result};3use std::path::PathBuf;45fn main() -> Result<()> {6 let args: Vec<String> = std::env::args().collect();7 let default_input = oa::Path::asset_rel("image/coverMl.jpg");8 let in_path: PathBuf = args9 .get(1)10 .map(PathBuf::from)11 .unwrap_or(default_input.into());12 let out_path: PathBuf = args13 .get(2)14 .map(PathBuf::from)15 .unwrap_or_else(|| PathBuf::from("/tmp/oa_viewport_batch.png"));1617 // ── Engine bring-up — headless (pure compute) ─────────────────────────────18 // No surface, no VK_KHR_swapchain. Any GPU admitted by the driver works.19 let engine = Engine::builder().build()?;2021 eprintln!(22 "tu_viewer_image_headless: {} → {}",23 in_path.display(),24 out_path.display()25 );2627 // ── Producer: decode packed pixels and upload directly as a Texture ─────28 let tex = texture_from_file(&engine, &in_path)?;2930 // ── Sink: save to file (readback + encode + write) ────────────────────────31 save_texture_file(&tex, &out_path, 90)?;32 println!(33 "OK: {}×{} {} → {}",34 tex.width(),35 tex.height(),36 in_path.display(),37 out_path.display()38 );3940 // ── Smoke: blit (GPU copy — should round-trip to original) ───────────────41 let blit_path = PathBuf::from("/tmp/oa_viewport_batch_blit.png");42 let clone = blit(&tex)?;43 save_texture_file(&clone, &blit_path, 90)?;44 println!("OK: Blit → {}", blit_path.display());4546 // ── Smoke: clear (solid red) ──────────────────────────────────────────────47 let clear_path = PathBuf::from("/tmp/oa_viewport_batch_clear.png");48 let red = clear(&clone, oa::Color::new(0.95, 0.10, 0.10, 1.0))?;49 save_texture_file(&red, &clear_path, 90)?;50 println!("OK: clear(red) → {}", clear_path.display());5152 Ok(())53}54
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.