Expand description
egui / eframe integration for the cameras crate.
This crate owns only the thin glue between a running
cameras::pump::Pump and an egui::TextureHandle. Every camera
primitive (pause / resume, single-frame capture, hotplug, source
abstraction) lives upstream in cameras itself and is re-exported here
for convenience.
§Wiring an eframe app
ⓘ
use egui_cameras::cameras::{self, PixelFormat, Resolution, StreamConfig};
use eframe::egui;
struct App {
stream: egui_cameras::Stream,
}
impl eframe::App for App {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
let ctx = ui.ctx().clone();
egui_cameras::update_texture(&mut self.stream, &ctx).ok();
egui::CentralPanel::default().show_inside(ui, |ui| {
egui_cameras::show(&self.stream, ui);
});
ctx.request_repaint();
}
}The doctest is ignored because it uses eframe, which egui-cameras
does not depend on. The apps/egui-demo app in this repo is the
runnable version.
Re-exports§
pub use cameras;
Structs§
- Pump
- A running camera pump.
- Sink
- Shared slot that a
Pumpwrites each frame into. - Stream
- A running camera pump plus an
egui::TextureHandlethat is refreshed each timeupdate_textureis called.
Functions§
- capture_
frame - Request a single fresh frame from the pump.
- frame_
to_ color_ image - Convert a cameras
Frameinto an eguiColorImage(RGBA8). - publish_
frame - Publish
frametosink, replacing any previous frame. - set_
active - Toggle whether the pump actively streams frames to its sink.
- show
- Draw the stream’s texture into
uias a sizedegui::Imagethat fills the available width while preserving aspect ratio. - spawn
- Spawn a pump that feeds a fresh
Streambacked by a default-named texture. The returnedStreamis in the active state. - spawn_
named - Like
spawn, but lets you name the egui texture. Useful when you have more than one concurrent camera stream in the same app. - spawn_
pump - Spawn a
Pumpthat writes each incoming frame intosink. Use this when you want to manage theSinkandTextureHandleyourself instead of bundling them in aStream. - stop_
and_ join - Consume the pump, signal the worker to stop, and block until it has exited.
- take_
frame - Take the latest frame out of
sink, returningNoneif no frame has arrived since the last call. - update_
texture - Upload the latest frame on
stream’sSinkto itsTextureHandle.