通过DirectX / C#访问视频捕获卡 [英] Accessing a video capture card via DirectX/C#

查看:114
本文介绍了通过DirectX / C#访问视频捕获卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我一直在使用DirectX从我们的视频  Capture 卡中流式传输视频一段时间没有问题。  我们使用的卡片带有4个单独的芯片,因此设备管理器中存在4个单独的实例,每个
实例代表一个摄像头。

I have been using DirectX to stream video from our Video Capture cards for a while now with no issue.  The cards we have been using come with 4 separate chips, so 4 separate instances existing in the device manager, each instance representing a single camera.

我们最近切换到新卡,在设备管理器中有一个芯片和一个实例(Conexant,如果重要的话)。  我只能从连接到卡上的第一台相机进行流式传输(我需要能够同时传输所有四个相机)。  我附上
我的代码用于连接到卡并访问第一台摄像机,任何帮助都会非常值得赞赏。  传入的SystemID是卡片的Monicker字符串,在这种情况下,它是:"@ device:pnp:\\?\\\ pci#ven_14f1& dev_8200& subsys_001014f1& rev_00#4& 1b89d1f& ; 0& 00e0#{65e8773d-8f56-11d0-a3b9-00a0c9223196} \ {9b365890-165f-11d0-a195-0020afd156e4}"

We have recently switched to new cards, with one chip and one instance in the device manager (Conexant if it matters).  I am only able to stream from the first camera attached to the card (i need to be able to stream all four at once).  I've attached my code for connecting to the card and accessing the first camera, any help would be GREATLY appreciated.  The SystemID that is being passed in is the Monicker string of the card, in the case, it's: "@device:pnp:\\?\pci#ven_14f1&dev_8200&subsys_001014f1&rev_00#4&1b89d1f&0&00e0#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{9b365890-165f-11d0-a195-0020afd156e4}"

public void OpenCamera(string SystemID)
        {
             CloseCamera();

            Guid cat;
            Guid med;
            int hr;

            const int WS_CHILD = 0x40000000;
            const int WS_CLIPCHILDREN = 0x02000000;
            const int WS_CLIPSIBLINGS = 0x04000000;

            graphBuilder = (IGraphBuilder)Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.FilterGraph, true));

            Guid clsid = Clsid.CaptureGraphBuilder2;
            Guid riid = typeof(ICaptureGraphBuilder2).GUID;
            captureGraphBuilder = (ICaptureGraphBuilder2)DsBugWO.CreateDsInstance(ref clsid, ref riid);

            if (captureGraphBuilder.SetFiltergraph(graphBuilder) == 0)
            {
                videoDeviceFilter = (IBaseFilter)Marshal.BindToMoniker(SystemID);

                if (graphBuilder.AddFilter(videoDeviceFilter, "Video Capture Device") == 0)
                {

                    object o;
                    cat = PinCategory.Preview;
                    med = MediaType.Interleaved;
                    Guid iid = typeof(IAMStreamConfig).GUID;
                    hr = captureGraphBuilder.FindInterface(ref cat, ref med, videoDeviceFilter, ref iid, out o);

                    if (hr != 0)
                    {
                        cat = PinCategory.Preview;
                        med = MediaType.Video;
                        hr = captureGraphBuilder.FindInterface(ref cat, ref med, videoDeviceFilter, ref iid, out o);

                        if (hr != 0)
                            o = null;
                    }

                    videoStreamConfig = o as IAMStreamConfig;

                    mediaControl = (IMediaControl)graphBuilder;

                    cat = PinCategory.Preview;
                    med = MediaType.Video;
                    if (captureGraphBuilder.RenderStream(ref cat, ref med, videoDeviceFilter, null, null) >= 0)
                    {
                        videoWindow = (IVideoWindow)graphBuilder;

                        if (videoWindow.put_Owner(pnlCamWindow.Handle) >= 0)
                        {
                            if (videoWindow.put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS) >= 0)
                            {
                                OnResize(null);

                                if (videoWindow.put_Visible(DsHlp.OATRUE) >= 0)
                                {
                                    mediaControl.Run();
                                    btnCardProperties.Enabled = true;
                                }
                            }
                        }
                    }
                }
            }
        }

我很乐意澄清一下是否有任何意义。  提前致谢。

I'll be happy to clarify if anything doesn't quite make sense.  Thanks in advance.

推荐答案

Hi Malevento ,

感谢您的帖子。

根据对于你的问题,我认为DirectX论坛对你更好,因为在这个领域有更多经验丰富的专家。请尝试使用DirectX论坛:
http://forums.create.msdn.com/forums/?GroupID = 7

很抱歉给您带来不便。

有美好的一天。


这篇关于通过DirectX / C#访问视频捕获卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆