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

Function dump_capabilities

rustcv-backend-v4l2/examples/camera_view.rs:213–252  ·  view source on GitHub ↗
(dev_path: &str)

Source from the content-addressed store, hash-verified

211
212#[cfg(target_os = "linux")]
213fn dump_capabilities(dev_path: &str) -> anyhow::Result<()> {
214 println!("--- Inspecting capabilities for: {} ---", dev_path);
215
216 // 【关键修复】显式引入枚举和它的变体结构体
217 use v4l::framesize::FrameSizeEnum;
218
219 let dev = v4l::Device::with_path(dev_path)?;
220 let formats = dev.enum_formats()?;
221
222 for fmt in formats {
223 println!("[Format] {} ({})", fmt.fourcc, fmt.description);
224
225 match dev.enum_framesizes(fmt.fourcc) {
226 Ok(sizes) => {
227 for size in sizes {
228 // 【关键修复】使用引入的 FrameSize 枚举进行匹配
229 match size.size {
230 FrameSizeEnum::Discrete(d) => {
231 println!(" - {}x{}", d.width, d.height);
232 }
233 FrameSizeEnum::Stepwise(s) => {
234 println!(
235 " - Stepwise: {}x{} to {}x{} (step {}x{})",
236 s.min_width,
237 s.min_height,
238 s.max_width,
239 s.max_height,
240 s.step_width,
241 s.step_height
242 );
243 }
244 }
245 }
246 }
247 Err(e) => println!(" - Failed to get sizes: {}", e),
248 }
249 }
250 println!("----------------------------------------\n");
251 Ok(())
252}
253
254#[cfg(not(target_os = "linux"))]
255fn main() {

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected