【发布时间】:2020-12-18 08:25:03
【问题描述】:
我正在尝试弄清楚如何检查网络摄像头/视频捕获设备是否已被另一个应用程序使用而没有实际激活它。
我目前的方法是使用 AForge.NET 库并使用 VideoCaptureDevice 对象的 .IsRunning 属性,如下所示:
var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo videoDevice in videoDevices)
{
VideoCaptureDevice camera new AForge.Video.DirectShow.VideoCaptureDevice(videoDevice.MonikerString);
Debug.Print(camera.IsRunning)
}
我猜 IsRunning 属性仅适用于已使用库启动的 VideoCaptureDevices,我需要对设备进行较低级别的 DirectShow 访问。
虽然在 C# 中使用 DirectShow 有很多方法,但即使在 C++ 中使用 DirectShow,我也无法找到检查状态的方法。我需要在这里施展什么魔法吗?
谢谢
托拜厄斯·蒂佩
【问题讨论】:
-
我想你可以注册一个CameraCaptureStateChanged 活动。
-
听起来很有趣,我去看看,谢谢!
-
IInspectable提供的方法对你有用吗?
-
不是真的,它只支持 UWP 应用程序,而我的应用程序应该使用 NotifyIcon 在后台运行。
-
你验证了吗?该文档经常过时,并且经常没有将
DualApiPartitionAttribute命名为 可用于经典桌面应用程序的类型。实际上,仅 UWP 的 WinRT 类型的数量接近于零。
标签: c# c++ winapi directshow aforge