l1npengtul / nokhwa

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

How to detect, if camera is open on windows. #104

Open thinkrapido opened 1 year ago

thinkrapido commented 1 year ago

I have this here

let mut is_streaming = false;
        for idx in 0..4u32 {
            if let Err(NokhwaError::SetPropertyError{..}) = Camera::new(nokhwa::utils::CameraIndex::Index(idx), RequestedFormat::new::<LumaFormat>(nokhwa::utils::RequestedFormatType::None)) {
                is_streaming = true;
                break;
            }
        }

This works pretty good for linux, but I can't detect if the camera is open/streaming/on with any specific desktop app.

Can someone help me out, or is ther no functionality for this in nokhwa?

OlivierLDff commented 1 year ago

You need to start streaming on windows, since mf backend allow multiple camera handle to point to the same internal camera. Only one handle can open streaming