MCPcopy Create free account
hub / github.com/RustCV/RustCV / next_frame

Method next_frame

rustcv-backend-v4l2/src/stream.rs:66–103  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

64 }
65
66 async fn next_frame(&mut self) -> Result<Frame<'_>> {
67 if !self.is_streaming {
68 return Err(CameraError::Io(io::Error::other("Stream not started")));
69 }
70
71 // 调用 CaptureStream 的 next
72 let (buf, meta) = self.inner.next().map_err(CameraError::Io)?;
73 let arrival_time = Instant::now();
74
75 let hw_ns =
76 (meta.timestamp.sec as u64 * 1_000_000_000) + (meta.timestamp.usec as u64 * 1_000);
77
78 let synced_time = self.clock_sync.correct(hw_ns, arrival_time);
79
80 let metadata = FrameMetadata {
81 actual_exposure_us: None,
82 actual_gain_db: None,
83 trigger_fired: false,
84 strobe_active: false,
85 };
86
87 let frame = Frame {
88 data: buf,
89 width: self.format.width,
90 height: self.format.height,
91 stride: meta.bytesused as usize / self.format.height as usize,
92 format: crate::pixel_map::from_v4l_fourcc(self.format.fourcc),
93 sequence: meta.sequence as u64,
94 timestamp: Timestamp {
95 hw_raw_ns: hw_ns,
96 system_synced: synced_time,
97 },
98 metadata,
99 backend_handle: &V4L2_HANDLE_INSTANCE,
100 };
101
102 Ok(frame)
103 }
104
105 #[cfg(feature = "simulation")]
106 async fn inject_frame(&mut self, _frame: Frame<'_>) -> Result<()> {

Callers 4

spawn_camera_producerFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 2

from_v4l_fourccFunction · 0.85
correctMethod · 0.80

Tested by

no test coverage detected