我有一些使用 Directshow.Net 库的代码(Winforms、C#、.Net 4)。我现在遇到了 2 次问题,其中设备有一个“网络摄像头”,但它没有在设备管理器中显示为成像设备,而是作为其他设备显示。发生这种情况时,DirectShow.Net 要么无法识别它,要么识别它足以与它一起工作,但如果我尝试捕获视频,它就会爆炸。这最近发生在运行 Windows 10 的 Microsoft Surface Pro 4 上。有人对此有任何想法吗?为什么会发生或如何解决?硬件接口不是我的专长,这是我唯一处理直接硬件接口的产品代码。
答案可以是 VB 或 C#(或任何其他语言)。
谢谢
编辑:我相信错误发生在这行代码(来自 DirectShow.Net 库),完整的函数调用进一步向下:
hr = m_VidControl.SetMode(m_pinStill, VideoControlFlags.Trigger);
我无法确定这一点,因为我无权在具有实际上不是网络摄像头的网络摄像头的设备上进行开发
返回的错误是
System.Runtime.InteropServices.COMException (0x80070032): The request is not supported.
at DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)
完整功能代码:
public IntPtr Click()
{
int hr;
// get ready to wait for new image
m_PictureReady.Reset();
m_ipBuffer = Marshal.AllocCoTaskMem(Math.Abs(m_stride) * m_videoHeight);
try
{
m_WantOne = true;
// If we are using a still pin, ask for a picture
if (m_VidControl != null)
{
// Tell the camera to send an image
hr = m_VidControl.SetMode(m_pinStill, VideoControlFlags.Trigger);
DsError.ThrowExceptionForHR(hr);
}
// Start waiting
if (!m_PictureReady.WaitOne(9000, false))
{
throw new Exception("Timeout waiting to get picture");
}
}
catch
{
Marshal.FreeCoTaskMem(m_ipBuffer);
m_ipBuffer = IntPtr.Zero;
throw;
}
// Got one
return m_ipBuffer;
}