l1npengtul / nokhwa

Cross Platform Rust Library for Powerful Webcam/Camera Capture
Apache License 2.0
504 stars 125 forks source link

Wrong Platform - Not Selected Error on Example, Windows 10 #14

Closed DataScienceLeadJr closed 2 years ago

DataScienceLeadJr commented 2 years ago

Hi,

I've ended up copy-pasting the code from the example to make sure it's not something I introduced by mistake.

Same behaviour for 0.6.0 and 0.7.0.

I am not able to figure out what it is, just wondering if it is an access problem, but not finding a way to fix it.

I got logitech UVC webcam, windows 10 Home, Gstreamer and OpenCV installed, not from WSL, admin cmd, made sure python from the same terminal could capture from the webcam with opencv-for-python.

Does it sound like a classic rust - Windows 10 problem you know of or something?

l1npengtul commented 2 years ago

What features do you have enabled? Any stacktrace, console output, etc? I need more info to help you.

I also have a fix incoming for MediaFoundation soon. 0.8.0 Fixed

DataScienceLeadJr commented 2 years ago

stacktrace for specified backend (same behaviour for all of them):

cargo run -- -c 0 -b UVC

Finished dev [unoptimized + debuginfo] target(s) in 0.16s
 Running `target\debug\capture-example.exe -c 0 -b UVC
 `thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: NotImplementedError("Platform
 requirements not satisfied. (Wrong Platform - Not Selected)")', src\main.rs:132:88
stack backtrace:
 0: std::panicking::begin_panic_handler
           at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\std\src\panicking.rs:515
 1: core::panicking::panic_fmt
           at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\core\src\panicking.rs:92
 2: core::result::unwrap_failed
           at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\core\src\result.rs:1599
 3: enum$<core::result::Result<nokhwa::camera::Camera,enum$<nokhwa::error::NokhwaError> > >::unwrap<nokhwa::camera::Camera,enum$<nokhwa::error::NokhwaError> >
           at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\library\core\src\result.rs:1281
 4: capture_example::main::closure$0
           at .\src\main.rs:132
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Thread terminated, closing!

For querying, on auto:

cargo run -- -c 0 -q

Finished dev [unoptimized + debuginfo] target(s) in 0.17s
 Running `target\debug\capture-example.exe -c 0 -q
`thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: NotImplementedError("Platform
requirements not satisfied. (No Selection)")', src\main.rs:132:88
stack backtrace:
0: std::panicking::begin_panic_handler
         at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\std\src\panicking.rs:515
1: core::panicking::panic_fmt
         at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\core\src\panicking.rs:92
2: core::result::unwrap_failed
         at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\core\src\result.rs:1599
3: enum$<core::result::Result<nokhwa::camera::Camera,enum$<nokhwa::error::NokhwaError> > >::unwrap<nokhwa::camera::Camera,enum$<nokhwa::error::NokhwaError> >
         at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\library\core\src\result.rs:1281
4: capture_example::main::closure$0
         at .\src\main.rs:132
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Thread terminated, closing!

I've tried running it with just the one feature I'm trying use as backend, e.g. input-gst. I've tried with the set of windows relevant ones, and with all of them. Same behaviour no matter what.

DataScienceLeadJr commented 2 years ago

realised I have nokhwa as

[dependencies.nokhwa]
version = "0.7.0"

instead of

[dependencies.nokhwa]
path = "../../../nokhwa"

as only not-copy-pasted difference.

l1npengtul commented 2 years ago

Try enabling input-uvc and input-msmf. You only have the gstreamer backend enabled. The preferred backend for Windows is input-msmf

DataScienceLeadJr commented 2 years ago

with only those two enabled I still get: Failed to query: This operation is not supported by backend UniversalVideoClass/MediaFoundation. from -q MSMF/UVC -b MSMF/UVC

with the following same NotImplementedError("Platform requirements not satisfied. (Wrong Platform - Not Selected)")

Is it starting to sound like it's the setup that is the problem around it? Doublechecked the driver for the camera.

You can tell me to give up on windows, I need the push anyways.

l1npengtul commented 2 years ago

If you can upload the code I can look over it, it works fine with MSMF and a logitech C920 on my machine.

DataScienceLeadJr commented 2 years ago

sorry, was away from the comp.

It is honestly exactly you example code in capture/main.rs

As in when my small re-writing of it didn't work I ctrl+a ctrl+c ctrl+v that, and when that didn't work I did the same for the toml and planned to have that work, and then find the small change I had introduced that crashed it.

So that is kinda the awkward part, I don't have a minimal reproducible example, just your example ^^

But I have the Logitech Streamcam, as only difference that I can see. It is "[...] optimized for Open Broadcaster Software (OBS), XSplit and Streamlabs [...]" and I see now that it isn't on the list of UVC cameras, but it is UVC as mentioned several places including specific issues for versions of linux

l1npengtul commented 2 years ago

Sorry, had a hectic week. Try this exact command:

cargo run --features "input-msmf" -- -q

If that doesn't work I honestly have no idea - you may want to check your webcam works with other MSMF software or update your windows machine.

DataScienceLeadJr commented 2 years ago

specifying the feature in the run command worked! also gave actual information about why my uvc setup wasn't working :+1:

Thanks!

l1npengtul commented 2 years ago

Oh yeah, I forgot that libuvc doesn't work on windows :P (I'll fix it in time)