l1npengtul / nokhwa

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

Switching devices leads to assertion failure at the device list. #164

Open caseykneale opened 4 months ago

caseykneale commented 4 months ago

I tried to write some code where I switched devices with the V4L backend. IE:

When I get to the open stream phase of this I get an assertion failure:

thread '<unnamed>' panicked at /home/cake/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/8ac5ce9/nokhwa-bindings-linux/src/lib.rs:193:13:
assertion `left == right` failed: Device list should not contain duplicate indexes

Ordinarily I would share code but this is easily reproduced. I've tried pretty much every pattern to avoid this. From mutating the camera instance by changing it's device id (same error), not closing the streams, not opening a new stream etc.

Ultimately I'm not sure why a global device list is creating a new device entry. I tried inspecting the docs for what happens when a stream is closed, it says there are quirks and to check the backend portion of the docs. Those notes seem to be missing?

Is there a preferred method to switch devices, is this currently unsupported, or broken?

caseykneale commented 4 months ago

For anyone wondering the OpenCV crate does support this functionality without any issues.