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

Method open_with

rustcv-camera/src/camera.rs:75–93  ·  view source on GitHub ↗

Open a camera with custom configuration. 使用自定义配置打开摄像头。 # Examples ```no_run use rustcv_camera::{Camera, CameraConfig, PixelFormat}; let cam = Camera::open_with(0, CameraConfig::new() .resolution(1280, 720) .fps(60) .pixel_format(PixelFormat::Yuyv) .buffer_count(8) ).unwrap(); ```

(index: u32, config: CameraConfig)

Source from the content-addressed store, hash-verified

73 /// ).unwrap();
74 /// ```
75 pub fn open_with(index: u32, config: CameraConfig) -> Result<Self> {
76 // Linux: V4L2 uses /dev/videoN device paths.
77 // macOS / Windows: backends use the numeric index as a string.
78 // Linux:V4L2 使用 /dev/videoN 设备路径。
79 // macOS / Windows:后端使用数字索引的字符串形式。
80 #[cfg(target_os = "linux")]
81 let device_path = format!("/dev/video{}", index);
82 #[cfg(not(target_os = "linux"))]
83 let device_path = format!("{}", index);
84
85 let mut backend = backend::PlatformBackend::new();
86 let resolved = backend.open(&device_path, &config)?;
87 backend.start()?;
88
89 Ok(Self {
90 backend,
91 config: resolved,
92 })
93 }
94
95 /// Capture the next frame (zero-copy).
96 /// 采集下一帧(零拷贝)。

Callers

nothing calls this directly

Calls 2

openMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected