How to define that camera is busy by another application using OpenCVSharp4

Viewed 134

I'm using OpenCVSharp4 and It necessary to make a capture from webcam.

But sometimes camera could be busy by another application as Skype, Teams, etc.

I try to use IsOpened() method to define that, but it returns true when webcam is busy and makes black capture. (I've used default windows 10 Camera application to make my webcamera busy)

        using (var videoCapture = new VideoCapture(0))
        using (var frame = new Mat())
        {

            if (videoCapture.Open(0) && videoCapture.IsOpened())
            {
                if (videoCapture.Read(frame) && !frame.Empty())
                {
                    var image = frame.ToBitmap();
                    return image;
                }
            }
        }

Also I've tried to use -1 instead of 0 as a parameter of Open method, but it is totally not working by that way.

Does anybody have an idea how can I deal with that issue, and correctly define that camera is busy?

0 Answers
Related