How to open camera capture while in use in another program?

I wrote an app to capture and display the video from my webcam, with a slider to change the camera exposure. Works great.

However, I want this so I can adjust my camera exposure before entering a web meeting, and I would like to run it while the web meeting preview is open, and this doesn’t work. If I open the web meeting preview first then the opencv capture doesn’t work. If I run my app first then the web meeting preview fails to initialize the camera.

I can create a VideoCapture object, and capture.Open() works (or at least capture.IsOpened() is true, and settings such as exposure seem correct) but capture.Grab() returns false, and capture.RetrieveMat() returns an empty material.

Is there an option to open the capture device in non-exclusive mode, so that my app and the web meeting preview can both access the camera? I know in theory this is possible, because I can use other third party apps (e.g. OBS Studio) to capture the camera while the web meeting preview is active.

I’m using Windows 10, with the OpenCVSharp4 C# wrapper in a WPF application. My web meeting software is Google Meet. I hope none of this matters and that there is a feature of VideoCapture that I need to use in order to enable non-exclusive access to the camera.

Thanks for any suggestions!

short answer: use that.

sorry, but there’s no such thing here

idk, which backend this is using, but at least with DSHOW there are persistent params (saved in the registry) , which you can access via `capture.get(CAP_PROP_SETTINGS) or even from VLC or such. in other words, it might not be nessecary to have 2 progs accessing the same cam at the same time.

in the end, opencv is a computer-vision library. ( and your problem sounds like the wrong use-case)

Thanks for your replay and the advice. Looking at the opencv source code, I see that the capture initialization settings do not set the sharing mode, so it must default to exclusive control. This could be modified, but in its current form you are correct, the library will not do what I want.

I agree that opencv is overkill for my application, but it did allow me to get my app up and running in about an hour. :sweat_smile:

I’ll look for simpler Windows media sample code and base my app on that instead.