2

我想使用我的 macbook 的 *Built-in iSight" 相机(我在训练营下)。

我创建了一个使用DirectShow图形从网络摄像头读取视频流的简单程序。这是 *Form1_Load()* 方法:

private void Form1_Load(object sender, EventArgs e)
{
    int hr = 0;

    _graphBuilder = (IGraphBuilder)new FilterGraph();
    Console.WriteLine("Create the VMR9 object");

    _vmr9 = (IBaseFilter)new VideoMixingRenderer9();

    Console.WriteLine("Configure the VMR9 for one stream");
    _filterConfig = (IVMRFilterConfig9)_vmr9;
    // One stream is enough for this sample
    _filterConfig.SetNumberOfStreams(1);

    _graphBuilder.AddFilter(_vmr9, "Video Mixing Renderer");


    Console.WriteLine("Change VMR9 mode to Windowless");
    hr = _filterConfig.SetRenderingMode(VMR9Mode.Windowless);
    Marshal.ThrowExceptionForHR(hr);

    _windowlessCtrl = (IVMRWindowlessControl9)_vmr9;

    Console.WriteLine("Set parent window");
    hr = _windowlessCtrl.SetVideoClippingWindow(this.Handle);
    Marshal.ThrowExceptionForHR(hr);

    Console.WriteLine("Set Aspect-Ratio");
    hr = _windowlessCtrl.SetAspectRatioMode(VMR9AspectRatioMode.None);
    Marshal.ThrowExceptionForHR(hr);

    Console.WriteLine("Set video position");
    hr = _windowlessCtrl.SetVideoPosition(null, DsRect.FromRectangle(this.ClientRectangle));
    Marshal.ThrowExceptionForHR(hr);

    Console.WriteLine("Building graph...");

    ICaptureGraphBuilder2 pBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
    hr = pBuilder.SetFiltergraph(_graphBuilder);
    checkHR(hr, "Can't SetFiltergraph");

    Guid CLSID_WDMStreamingCaptureDevices = new Guid("{65E8773D-8F56-11D0-A3B9-00A0C9223196}"); //

    //add Built-in iSight
    IBaseFilter pBuiltiniSight = CreateFilterByName(@"Built-in iSight", CLSID_WDMStreamingCaptureDevices);
    hr = _graphBuilder.AddFilter(pBuiltiniSight, "Built-in iSight");
    checkHR(hr, "Can't add Built-in iSight to graph");

    //connect Built-in iSight and Video Renderer
    hr = _graphBuilder.ConnectDirect(GetPin(pBuiltiniSight, "Capturer"), GetPin(_vmr9, "VMR Input0"), null); // => Program hungs up!!!
    checkHR(hr, "Can't connect Built-in iSight and Video Renderer");

    Console.WriteLine("Running...");
    mediaControl = (IMediaControl)_graphBuilder;
    hr = mediaControl.Run();
    checkHR(hr, "Can't run the graph");
}

调用ConnectDirect()方法时程序卡住了...

它用来工作。使用视频渲染器过滤器时效果很好,但我需要使用视频混合渲染器 9。

我使用TraceSpy来捕获以下跟踪:

Direct3D9: :====> ENTER: DLLMAIN(581fd9a0): Process Attach: 00000a70, tid=00000658
Direct3D9: :====> EXIT: DLLMAIN(581fd9a0): Process Attach: 00000a70
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO
Direct3D9: (INFO) :======================= Hal SWVP device selected
Direct3D9: (INFO) :HalDevice Driver Style b
Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :Using FF to PS converter
Direct3D9: (INFO) :Enabling multi-processor optimizations
Direct3D9: (WARN) :Athlon32Compiler: CPU does not meet minimum requirements
Direct3D9: (INFO) :Using P4 PSGP
Direct3D9: (INFO) :Using FF to VS converter in software vertex processing
Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode
Direct3D9: :DoneExclusiveMode
Direct3D9: (ERROR) :Invalid format specified for texture
4

0 回答 0