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

Function set_fps

rustcv-camera/src/backend/linux/sys.rs:215–227  ·  view source on GitHub ↗

Set the frame rate via VIDIOC_S_PARM. 通过 VIDIOC_S_PARM 设置帧率。 Frame rate is expressed as a fraction: `timeperframe = numerator / denominator`. For 30fps: numerator=1, denominator=30. 帧率用分数表示:`timeperframe = 分子 / 分母`。 30fps 对应:分子=1,分母=30。

(fd: RawFd, fps: u32)

Source from the content-addressed store, hash-verified

213/// 帧率用分数表示:`timeperframe = 分子 / 分母`。
214/// 30fps 对应:分子=1,分母=30。
215pub fn set_fps(fd: RawFd, fps: u32) -> io::Result<v4l2_streamparm> {
216 let mut parm: v4l2_streamparm = unsafe { std::mem::zeroed() };
217 parm.type_ = V4L2_BUF_TYPE_VIDEO_CAPTURE;
218
219 let capture = unsafe { &mut parm.parm.capture };
220 capture.timeperframe.numerator = 1;
221 capture.timeperframe.denominator = fps;
222
223 unsafe {
224 v4l2_ioctl(fd, VIDIOC_S_PARM, &mut parm as *mut _ as *mut libc::c_void)?;
225 }
226 Ok(parm)
227}
228
229// ─── Controls ───────────────────────────────────────────────────────────────
230

Callers 1

openMethod · 0.85

Calls 1

v4l2_ioctlFunction · 0.85

Tested by

no test coverage detected