【问题标题】:capture image from webcam c# WPF app从网络摄像头 c# WPF 应用程序捕获图像
【发布时间】:2012-07-06 15:28:34
【问题描述】:

我正在尝试为 WPF/C# 中的一个应用程序从网络摄像头捕获图像

1) 我尝试了 WIA,但我发现错误 0x80210015,我已经读到当没有可用的 WIA 设备时会发生此错误。我读到在 windows vista/7 WPD 中使用了 insted WIA 但是当我尝试一个简单的例子时

PortableDeviceManager deviceManager = new PortableDeviceManager();
deviceManager.RefreshDeviceList();

uint numberOfDevices = 1;

deviceManager.GetDevices(null, ref numberOfDevices);

if (numberOfDevices == 0)
{
    Console.WriteLine("No device");
}
else
{
    string[] deviceIds = new string[numberOfDevices];
    deviceManager.GetDevices(ref deviceIds[0], ref numberOfDevices);

    Console.WriteLine(deviceIds);
}

Console.Read();

我无法检测到设备。

2) 我尝试使用http://easywebcam.codeplex.com/ 工作,但我随机收到错误“捕获视频图像时发生错误。视频捕获...”并且我需要始终选择设备并且我需要执行 webcam.start () 几次(2 或 3 次)才能使该相机正常工作。

我有两个网络摄像头

  • 群光 Web 2.0(内置网络摄像头)
  • Genius FaceCam 2000

【问题讨论】:

    标签: c# wpf webcam image


    【解决方案1】:

    这是一个简单的拍照类程序

      Image<Bgr, Byte> img; 
        private Capture capture;
        private bool captureInProgress;
    
        private void gumb_kamera_Click(object sender, EventArgs e)
        {
    
        }
    
        private void processFunction(object sender, EventArgs e)
        {
             img = capture.QueryFrame();
    
           //  imageBox1.Image = img;
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            if (capture == null)
            {
                try
                {
                    capture = new Capture(0);
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
    
            if (capture != null)
            {
                if (captureInProgress)
                {
                    Application.Idle -= processFunction;
                }
                else
                {
                    Application.Idle += processFunction;
                }
                captureInProgress = !captureInProgress;
            }
    
    
    
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
    
    
    
        imageBox1.Image = img; 
    
        }
    

    【讨论】:

    • 哇,伙计,我已经花了好几个小时试图找到工作 EmguCV 什么都没有,教程,博客 olny 解决方案复制所有 dll 但仍然无法工作
    • 我在使用 EmguCV 时遇到问题,您能在 stackoverflow.com/q/11402314/816721 中帮助我
    • 我认为你需要扩展它来展示库和技术
    • 什么是捕获?这是哪个图书馆的?
    猜你喜欢
    • 2013-01-18
    • 1970-01-01
    • 2013-02-09
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多