{"record":{"id":"f45c06aaff7cc018","repo":"AprilNEA/OpenLogi","slug":"no-logitech-camera-found-snapshot","errorCode":null,"errorMessage":"no Logitech camera found","messagePattern":"no Logitech camera found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/snapshot.rs","lineNumber":30,"sourceCode":"\n#[derive(Debug, Args)]\npub struct SnapshotArgs {\n    /// Output PNG path.\n    #[arg(default_value = \"snapshot.png\")]\n    pub path: String,\n    /// Capture from the camera with this unique id (default: first Logitech).\n    #[arg(long)]\n    pub camera: Option<String>,\n}\n\npub fn run(args: SnapshotArgs) -> Result<()> {\n    let unique_id = match args.camera {\n        Some(id) => id,\n        None => openlogi_camera::enumerate_cameras()\n            .into_iter()\n            .next()\n            .map(|camera| camera.unique_id)\n            .ok_or_else(|| anyhow!(\"no Logitech camera found\"))?,\n    };\n\n    println!(\"capturing one frame from {unique_id} …\");\n    let frame = openlogi_camera::capture_frame(&unique_id, Duration::from_secs(5))\n        .map_err(|e| anyhow!(\"{e}\"))?;\n    // Frames are stored BGRA (gpui's order); PNG wants RGBA, so swap R/B once.\n    let mut rgba = frame.bgra;\n    for px in rgba.as_chunks_mut::<4>().0 {\n        px.swap(0, 2);\n    }\n    write_png(&args.path, frame.width, frame.height, &rgba)\n        .with_context(|| format!(\"writing {}\", args.path))?;\n    println!(\"wrote {}x{} → {}\", frame.width, frame.height, args.path);\n    Ok(())\n}\n\nfn write_png(path: &str, width: u32, height: u32, rgba: &[u8]) -> Result<()> {\n    let file = std::fs::File::create(path)?;","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/snapshot.rs#L12-L48","documentation":"`snapshot run` needs a camera unique id: if `--camera` is not given it takes the first camera from `openlogi_camera::enumerate_cameras()`. When enumeration returns an empty list, the `ok_or_else` turns the `None` into this anyhow error. It means no Logitech UVC camera was visible to the camera layer at all.","triggerScenarios":"Running the `snapshot` command without `--camera` while `enumerate_cameras()` returns zero Logitech cameras (the iterator's `.next()` is `None`).","commonSituations":"No camera plugged in or it is a non-Logitech webcam; the camera is claimed exclusively by another app (Zoom/Teams) or the OS; on macOS the Camera (TCC) permission was denied so enumeration is empty; a USB hub/dock dropped the device.","solutions":["Plug in the Logitech camera (or confirm it is a Logitech model, not another vendor).","Pass the explicit device with `--camera <unique-id>` after confirming its id via enumeration.","Close apps holding the camera exclusively, then retry.","On macOS, grant Camera permission to the process in System Settings → Privacy & Security → Camera.","Replug the camera / try another USB port to rule out enumeration flakiness."],"exampleFix":"// before\n$ openlogi snapshot out.png\nerror: no Logitech camera found\n\n// after — plug the camera in, or target it explicitly once its id is known\n$ openlogi snapshot out.png --camera \"usb:046d:085e\"","handlingStrategy":"fallback","validationCode":"let cameras = openlogi_camera::enumerate_cameras();\nif cameras.is_empty() {\n    eprintln!(\"no Logitech camera visible; check connection/permissions\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"// snapshot::run returns anyhow::Result; intercept the enumeration failure\nmatch snapshot_run(args) {\n    Err(e) if e.to_string().contains(\"no Logitech camera found\") => {\n        eprintln!(\"connect a Logitech camera or pass --camera <unique-id>\");\n    }\n    other => other?,\n}","preventionTips":["Enumerate cameras and fail fast with a friendly message before attempting capture.","On macOS confirm the Camera (TCC) permission is granted to the process.","Check for apps holding the camera exclusively before scripting captures."],"tags":["cli","camera","enumeration","hardware"],"backgroundTag":"entity-not-found","analyzedSha":"e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8","analyzedAt":"2026-09-13T03:07:16.451Z","contentChangedAt":"2026-09-13T03:07:16.451Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}