2

I'm using uvc to try and get frames from my webcam. Everything is working up to the point where I try and open the webcam device.

Code:

use uvc::{Context, Frame};

fn main() {
    let ctx = Context::new().expect("Could not create context");
    let dev = ctx
        .find_device(None, None, None)
        .expect("Could not find device");

    let devh = dev.open().expect("Could not open device");
}

Error:

thread 'main' panicked at 'Could not open device: Access'

This is all just part of an example in the Uvc github, really I don't have any clues of what's going on. I'm using Ubuntu 22.10.

I've tried using sudo cargo run instead, but rust isn't installed for root user, so it didn't work. I'd also prefer to avoid sudo if possible.

STerliakov
  • 4,983
  • 3
  • 15
  • 37
altywalty
  • 55
  • 6
  • 1
    `cargo run` is there for convenience, but you don't actually need `sudo` to build your code. You can use `cargo build` then call `sudo target/my_crate_name` if `sudo` is required for running your application. However, that assumes the problem requires `sudo` in the first place. It may just be another issue related to finding the device. – Locke Dec 19 '22 at 01:07
  • My computer has a little physical switch on the side that disables camera access and can't be toggled from software. While I'm very happy it's there, I also routinely forget it and get confused when my computer randomly can't find my camera. Is it possible that your device has a similar security measure that you've forgotten to toggle? – Silvio Mayolo Dec 19 '22 at 03:42

0 Answers0