pub struct U3vFrameStream { /* private fields */ }Expand description
Frames from a USB3 Vision camera, read on a thread of its own.
next_frame waits asynchronously,
next_frame_blocking on the calling thread;
neither needs the other. A stream from U3vStreamBuilder or
Camera::open_stream clears the device’s
StreamEnable when it is closed or dropped.
A transfer that fails is recovered from — the endpoint reset, the block
in progress lost and counted — and the stream goes on; a camera that is
unplugged ends it with U3vError::Disconnected as the source of the
error, and marks the camera’s transport lost
(U3vRegisterIo::is_lost).
let mut frames = camera.open_stream(U3vStreamOptions::default())?;
camera.acquisition_start()?;
while let Some(frame) = frames.next_frame().await? {
println!("{}x{} frame {}", frame.width, frame.height, frame.block_id);
}Implementations§
Source§impl U3vFrameStream
impl U3vFrameStream
Sourcepub fn start(stream: U3vStream) -> Self
pub fn start(stream: U3vStream) -> Self
Read frames from stream, a stream already configured and enabled on
the device. Nothing clears the device’s StreamEnable when it ends;
U3vStreamBuilder starts streams that do.
Sourcepub fn set_deliver_incomplete(&mut self, deliver: bool)
pub fn set_deliver_incomplete(&mut self, deliver: bool)
Also deliver frames that did not complete — a block given up before
its trailer, or one whose trailer reports an error — with their
FrameStatus saying how (default: off). Every incomplete frame is
counted in StreamStats::frames_incomplete either way.
Sourcepub fn set_time_sync(&mut self, time_sync: TimeSync)
pub fn set_time_sync(&mut self, time_sync: TimeSync)
Map device timestamps to host time with time_sync, fitted by
Camera::time_calibrate.
Sourcepub fn stats(&self) -> StreamStats
pub fn stats(&self) -> StreamStats
Snapshot the stream’s counters.
Sourcepub fn stats_handle(&self) -> StreamStatsAccumulator
pub fn stats_handle(&self) -> StreamStatsAccumulator
A clone of the counters’ handle, readable from any thread.
Sourcepub async fn next_frame(&mut self) -> Result<Option<Frame>, GenicamError>
pub async fn next_frame(&mut self) -> Result<Option<Frame>, GenicamError>
Receive the next frame. Ok(None) means the stream has ended.
Cancel-safe.
Sourcepub fn next_frame_blocking(
&mut self,
timeout: Duration,
) -> Result<Option<Frame>, GenicamError>
pub fn next_frame_blocking( &mut self, timeout: Duration, ) -> Result<Option<Frame>, GenicamError>
Wait up to timeout for the next frame on the calling thread:
Ok(None) when the stream has ended, GenicamError::Timeout when
nothing arrived.
Sourcepub fn stop(&self)
pub fn stop(&self)
Tell the reader to stop. It stops within a read poll; this does not
wait for it, close does.