c# - 从旧相机录制 C#
问题描述
有很多简单的方法可以找到连接的摄像头并从中记录,尽管它们都不起作用,因为使用的网络摄像头有点旧,我尝试使用Aforge和Ozeki Camera SDK,但它们都没有检测到摄像头,唯一的使用以下代码检测相机的方式:
首先是一个类来保存检测到的相机:
class USBDeviceInfo
{
public USBDeviceInfo(string deviceID, string pnpDeviceID, string description, string name)
{
this.DeviceID = deviceID;
this.PnpDeviceID = pnpDeviceID;
this.Description = description;
this.name = name;
}
public string DeviceID { get; private set; }
public string PnpDeviceID { get; private set; }
public string Description { get; private set; }
public string name { get; private set; }
}
然后使用以下方法检测它们:
using System.Management;
List<USBDeviceInfo> devices = new List<USBDeviceInfo>();
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(@"SELECT * FROM Win32_PnPEntity WHERE (PNPClass = 'Image' OR PNPClass = 'Camera')"))
collection = searcher.Get(); // gets all connected cameras devices
foreach (var device in collection)
{
devices.Add(new USBDeviceInfo(
(string)device.GetPropertyValue("DeviceID"),
(string)device.GetPropertyValue("PNPDeviceID"),
(string)device.GetPropertyValue("Description"),
(string)device.GetPropertyValue("Name")
));
}
现在检测到相机,我现在如何开始录制?
请注意,驱动程序已安装且摄像头工作正常
解决方案
推荐阅读
- angular - Angular中的渐进式上传文件
- python - 如何在开发过程中重命名 Flask WSGI App?
- laravel - 如何在 Laravel eloquent 中使用 via 对象获取数据?
- c++ - 尝试绘制存储在数组中的矩形,但只出现一个矩形?
- jenkins-pipeline - 在 Jenkins 中使用 kubectl 应用“deployment.yaml”时出错
- swift - 当我启动我的仅 xib 项目时,会出现两个窗口
- navigation - 此处 Maps SDK 插入字符串以播放音频
- elasticsearch - 在 Elastic 搜索中解码 JSON 和损坏的日志时出错
- node.js - Express-session mongodb 会话不持久
- django - 当我尝试在 django 中运行 makemigrations 命令时,它给了我一个错误