3

Visual Studio 2012で作業していて、C#を使用しており、ライブラリDirectShowLibを使用してWebカメラから写真を撮っていますが、別の写真を撮ろうとすると例外が発生します。

   DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)
   at SnapShot.Capture.SetupGraph(DsDevice dev, Int32 iWidth, Int32 iHeight, Int16 iBPP, Control hControl) in c:\Users\devel_000\Documents\Visual Studio 2012\Projects\ControlAcceso\ControlAcceso\Capture.cs:line 323
   at SnapShot.Capture..ctor(Int32 iDeviceNum, Int32 iWidth, Int32 iHeight, Int16 iBPP, Control hControl) in c:\Users\devel_000\Documents\Visual Studio 2012\Projects\ControlAcceso\ControlAcceso\Capture.cs:line 86
   at ControlAcceso.PhotoWindow..ctor() in c:\Users\devel_000\Documents\Visual Studio 2012\Projects\ControlAcceso\ControlAcceso\PhotoWindow.cs:line 32
   at ControlAcceso.CheckWindow.pbPhoto_Click(Object sender, EventArgs e) in c:\Users\devel_000\Documents\Visual Studio 2012\Projects\ControlAcceso\ControlAcceso\CheckWindow.cs:line 108
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at ControlAcceso.Program.Main() in c:\Users\devel_000\Documents\Visual Studio 2012\Projects\ControlAcceso\ControlAcceso\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

DxSnapの例[リンク]を使用して写真を撮っています。例外は、メソッドSetupGraph [リンク]でスローされます。

その線DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)が私の注意を引いた、それはどういう意味ですか?どうすればこれを修正できますか?

4

1 に答える 1

7

エラー-21470234460x800705AAERROR_NO_SYSTEM_RESOURCES「要求されたサービスを完了するためのシステムリソースが不足しています」です。(値を簡単かつ便利に読み取る方法については、この投稿とツールを参照してください)。HRESULT

最初に閉じずに2番目のパイプラインを開こうとしている可能性が高いと思います。また、ビデオキャプチャデバイスは排他的に開かれているため、まだアクティブな別のデバイスがある場合、パイプラインを開始することはできません。エラーコードはまさにこれを示唆しています。

これを回避するにはIMediaControl.Stop、前のフィルターグラフを呼び出して、不要になったCOMインターフェイスをで解放する必要がありますMarshal.ReleaseComObject

于 2012-08-24T20:23:05.257 に答える