Home > Forum > Check devices connected memory issue

Check devices connected memory issue

Sep 12 (3 months ago)
Fábio Antunes wrote
hello, first time posting

I am having a problem, i have instantiate a VideoCapture to capture image and i need to detected when the camera is disconnected
I created a timer that checks all the seconds the devices connected
VideoCapture test = new VideoCapture();
if(test.Video_CaptureDevices.Contains("device")){
...do stuff....
}
test.dispose();

Even that i am using dispose this action each time ocupies memory and never frees it, making the computer ram consumed goes through the roof.

I already try put it in a background worker and inside the timer and making using(VideoCapture test ....)
Also i cannot use Video_CaptureDevices on the one i am using to capture because it doesnt update the list of devices, only when its created.

Nothing has worked so far is there anyway to detect if the device is connected or not? Or am i doing something wrong?
Reply
1 Answer
Sep 12 (3 months ago)
Roman Minyaylov agent wrote
Hi

Sample code:

using DirectShowLib;

var devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
foreach (var device in devices)
{
Debug.WriteLine(device.FriendlyName);
}

DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice) returns currently available video capture devices.