Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
caseykneale opened this issue Mar 3, 2024 · 3 comments
Closed

Comments

@caseykneale
Copy link

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

  • I capture an image on device index 0. Effectively following an index.
  • Close the stream.
  • Create a new camera (say index 2)
  • open a stream
  • Capture a new image

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
Copy link
Author

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

wangjia184 added a commit to wangjia184/nokhwa that referenced this issue Sep 8, 2024
@wangjia184
Copy link

wangjia184 commented Sep 8, 2024

The bug is from these lines: https://github.com/wangjia184/nokhwa/blob/8890670bf107fe7252d416a480dbe696de4211a8/nokhwa-bindings-linux/src/lib.rs#L200-L207

A fix is here : kendfrey/nokhwa@0.10...wangjia184:nokhwa:0.10

you may try it

# https://github.com/l1npengtul/nokhwa/issues/177
# https://github.com/l1npengtul/nokhwa/issues/164
nokhwa = { version = "0.10.4", features = ["input-native"], git = "https://github.com/wangjia184/nokhwa.git", branch = "0.10" }

@caseykneale
Copy link
Author

Thanks for the fix and the reply I would say this is now closed :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants