【问题标题】:Capture Camera Feed from EasyCap 4ch USB DVR Device using DirectShow and DirectX.Capture C#使用 DirectShow 和 DirectX.Capture C# 从 EasyCap 4ch USB DVR 设备捕获摄像机源
【发布时间】:2013-09-27 15:24:09
【问题描述】:

我正在尝试从我最近获得的 EasyCap 4 通道 USB DVR 设备 中捕获摄像头馈送
我买了一个超级咪咪单色/彩色摄像机并将其连接到 DVR 设备并设法使用驱动程序正确设置设备“SMI Grabber”并安装设备随附的软件“超级浏览器”
我编写了一个简单的 Windows 窗体应用程序,其中包含一个 PictureBox 来查看摄像头提要
(底部有一个编辑)
代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DirectX.Capture;


namespace DirectShowWithCrossbar
{
    public partial class Form1 : Form
    {
        private CrossbarSource crossbar;
        private Filters filters;
        private Capture capture;
        public Form1()
        {
            InitializeComponent();

            filters = new Filters();
            capture = new Capture(filters.VideoInputDevices[0], filters.AudioInputDevices[0]);
            foreach (Filter device in filters.VideoInputDevices)
            {
                comboBox1.Items.Add(device);
            }
            if (comboBox1.Items.Count > 0)
                comboBox1.SelectedIndex = 0;
            foreach (Filter device in filters.AudioInputDevices)
            {
                comboBox2.Items.Add(device);
            }
            if (comboBox2.Items.Count > 0)
                comboBox2.SelectedIndex = 0;
            foreach (Source source in capture.VideoSources)
            {
                comboBox3.Items.Add(source);
            }
            if (comboBox3.Items.Count > 0)
                comboBox3.SelectedIndex = 0;
            ShowPropertPagesInMenuStrip();
            crossbar = (CrossbarSource)capture.VideoSource;
            crossbar.Enabled = true;
            capture.PreviewWindow = pictureBox1;
        }

        private void ShowPropertPagesInMenuStrip()
        {
            foreach (PropertyPage pro in capture.PropertyPages)
            {
                menusToolStripMenuItem.DropDownItems.Add(new ToolStripMenuItem(pro.Name));
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            capture.Cue();
            capture.Start();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            capture.Stop();
            capture.Dispose();
        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            capture.VideoSource = (Source)comboBox3.SelectedItem;
        }
    }
}

我在图片框中出现黑屏??

关闭我的应用程序后我错误地运行了 DVR 设备 附带的 SuperViewer 应用程序,然后打开我的应用程序然后我的图片框开始向我显示来自相机的提要,奇怪!!!原来软件的提要冻结了!!
DirectX.Capture 示例和源尝试了相同的结果http://www.codeproject.com/Articles/3566/DirectX-Capture-Class-Library
我也使用了 OpenCVTouchless 并且得到了相同的结果 :(
编辑:
我一直在搜索,发现我需要获取过滤器(IAMCrossbar),我认为这是问题DirectShow USB webcam changing video source,在 DirectX.Capture Wrapper 中应用此链接中的更改后,我仍然得到相同的结果:(
提前感谢您的任何帮助 Yaser

【问题讨论】:

  • 您可以尝试使用 OpenCV,这个库有一个名为 Emgu 的 C# 包装器,只需几行代码就可以解决问题...emgu.com/wiki/index.php/Main_Page
  • @user2247823 谢谢你,但我已经尝试过了,我得到了相同的结果:(
  • 我的猜测是问题出在驱动程序上,尤其是。它假定应用程序将首先设置横杆。很难猜测,也没有通用的解决方案。
  • 不确定是否是您的代码问题,因为您没有发布捕获实现。你可以尝试参考这篇文章--Webcam Capture
  • @RomanR。谢谢,我认为这是问题所在:(但你能告诉我如何做到这一点

标签: c# camera directshow directshow.net


【解决方案1】:

如果您的捕获设备有选项,可以从多个输入接口中选择一个,那么是的,您是对的,您需要使用 IAMCrossbar。

如果你想坚持 Directshow(正如其他人建议的 OpenCV),那么我会建议,

  1. 尝试在 C++/CLI dll 中构建所有捕获相关的代码,
  2. 用 C# 构建您的所有 UI。

您可以将此MP3 Player Sample Project 作为您的 dll 的起点。

对于捕获,AmCap 是一个详细的示例。

我的意思是,您需要将 AmCap 中的捕获代码放入上述 MP3 Player Sample dll 中,并将其公开给您的 C# 应用程序。

【讨论】:

    猜你喜欢
    • 2014-06-23
    • 2013-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-15
    • 1970-01-01
    相关资源
    最近更新 更多