我正试图从我最近得到的EasyCap 4声道DVR设备上捕捉到摄像头馈送。
我买了一台超级米米单色/彩色相机,并将它连接到DVR设备上,并设法用驱动程序"SMI Grabber"正确地设置了设备,并安装了设备"SuperViewer"附带的软件。
我还编写了一个简单的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;
}
}
}我在画框里有个黑屏幕??


在关闭我的应用程序后,我错误地运行了SuperViewer应用程序,该应用程序随DVR设备一起运行,然后打开我的应用程序,然后我的图片盒开始显示来自照相机的提要,!和原始软件的提要冻结了!

DirectX.Capture示例和源代码尝试使用相同的结果http://www.codeproject.com/Articles/3566/DirectX-Capture-Class-Library
我还使用了OpenCV和Touchless,并得到了相同的结果:
编辑:
我一直在搜索,并发现我需要得到过滤器(IAMCrossbar),我认为这就是问题DirectShow USB网络摄像头转换视频源,在应用了这个链接的变化之后,我仍然得到了相同的结果:(
谢谢您的帮助,Yaser
发布于 2013-09-23 22:49:16
如果您的捕获设备具有从多个输入接口中选择一个的选项,那么是的,您是正确的,您需要使用IAMCrossbar。
如果您想坚持使用Directshow(其他人建议使用OpenCV),那么我建议,
您可以将此MP3播放器示例项目作为dll的起点。
对于捕获,AmCap是一个详细的示例。
我的意思是,您需要将捕获代码从AmCap中提取到上面的MP3播放器示例dll中,并将其公开给您的C#应用程序。
https://stackoverflow.com/questions/18947263
复制相似问题