-
Notifications
You must be signed in to change notification settings - Fork 51
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
Detecting when webcam was unplugged #10
Comments
Not that I can think of.
…On Mon, Sep 4, 2017 at 11:14 PM, Boscop ***@***.***> wrote:
How can I detect when the webcam was unplugged?
In my loop I could check if countCaptureDevices() changed from last
frame, and if it did, I can check if the currently opened cam is still in
the list of connected ones, but is there a better way?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEQ_R2BMXxPgWuxXuMKHDHCoraCMcg7mks5sfFo-gaJpZM4PMOWh>
.
|
Has someone looked at this pull request? From the commits it suggests that someone solved this problem, plus there are some other goodies (like having a unique identifier for each camera). |
That seems useful! I'd appreciate if that PR got merged. |
Btw, what I do at the moment to check if the camera was disconnected since the last frame (with my Rust bindings) is: // TODO: count_devices() might be expensive, don't do every frame
pub fn is_connected(&mut self) -> bool {
let n = Capture::count_devices();
if self.camera_count == n {
true // might not be true if this cam got unplugged and another one plugged in since last frame
} else { // check if this cam is still plugged in
self.camera_count = n;
for i in 0..n {
if Capture::get_device_name(i) == self.cam_name {
return true;
}
}
false
}
} It works but it's not elegant. Btw, do you know if |
How can I detect when the webcam was unplugged?
In my loop I could check if
countCaptureDevices()
changed from last frame, and if it did, I can check if the currently opened cam is still in the list of connected ones, but is there a better way?The text was updated successfully, but these errors were encountered: