【问题标题】:WebCam Capture c# Logitech网络摄像头捕获 c# Logitech
【发布时间】:2020-10-28 08:35:31
【问题描述】:

我制作了这个程序,用于从我的 Logitech HD Pro WebCam c920 拍摄图像。

该程序实际上适用于集成摄像头,但是当我想使用我的罗技网络摄像头时 我什么都没有……(没有图像,没有错误)。

我想知道是否有人有同样的问题或可以帮助我解决它...

我的程序仅用于使用 aForge 在 c# 上从我的 WebCam 罗技拍摄照片。

我有这个代码:

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 Accord;
using AForge.Video;
using AForge.Video.DirectShow;

namespace WindowsFormsApp1
{
    public partial class Webcam : Form
    {
 public Webcam()
        {
            InitializeComponent();
        }
        FilterInfoCollection filterInfoCollection;
        VideoCaptureDevice videoCaptureDevice;
       
        private void btnStart_Click(object sender, EventArgs e)
        {
            videoCaptureDevice = new VideoCaptureDevice(filterInfoCollection[cboCamera.SelectedIndex].MonikerString);
            videoCaptureDevice.NewFrame += VideoCaptureDevice_NewFrame;
            videoCaptureDevice.Start();

        }

        private void VideoCaptureDevice_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            pic.Image = (Bitmap)eventArgs.Frame.Clone();
        }
        private void Webcam_Load(object sender, EventArgs e)
        {
            filterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach(FilterInfo filterinfo in filterInfoCollection)
            {
                cboCamera.Items.Add(filterinfo.Name);
                cboCamera.SelectedIndex = 0;
                videoCaptureDevice = new VideoCaptureDevice();
            }
        }

        private void Webcam_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (videoCaptureDevice.IsRunning == true)
                videoCaptureDevice.SignalToStop();
        }

btnstart 为按钮,cboCamera 为 Combobox,pic 为图片框。

【问题讨论】:

标签: c# webcam-capture logitech


【解决方案1】:

我有一个非常相似的问题。虽然我不知道为什么会发生这种情况,但我已经测试了以下解决方案:

  1. 使用Media Capture API - 似乎适用于所有网络摄像头,但我遇到了相当多的稳定性问题。
  2. 使用这个Versatile WebCam C# library - 似乎工作正常。

我还没有测试过Emgu/OpenCV,但这是另一种选择。

【讨论】:

    猜你喜欢
    • 2015-04-12
    • 1970-01-01
    • 2013-01-18
    • 2015-08-18
    • 1970-01-01
    • 1970-01-01
    • 2013-02-09
    相关资源
    最近更新 更多