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

Function create_driver

rustcv/src/videoio/backend.rs:13–37  ·  view source on GitHub ↗

创建驱动实例的工厂函数

()

Source from the content-addressed store, hash-verified

11
12/// 创建驱动实例的工厂函数
13pub fn create_driver() -> Result<Box<dyn Driver>> {
14 // 根据当前操作系统,直接选用原生后端 (不再需要 feature 门控)
15 #[cfg(target_os = "linux")]
16 {
17 Ok(Box::new(rustcv_backend_v4l2::V4l2Driver::new()))
18 }
19
20 #[cfg(target_os = "macos")]
21 {
22 Ok(Box::new(rustcv_backend_avf::AvfDriver::new()))
23 }
24
25 #[cfg(target_os = "windows")]
26 {
27 Ok(Box::new(rustcv_backend_msmf::MsmfDriver::new()))
28 }
29
30 #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
31 {
32 // 如果没有匹配的后端,返回错误
33 Err(anyhow!(
34 "No supported backend found for this OS. Please check Cargo features."
35 ))
36 }
37}
38
39/// 辅助:获取首选后端类型
40pub fn default_backend() -> BackendType {

Callers 1

newMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected