【发布时间】: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 为图片框。
【问题讨论】:
-
这能回答你的问题吗? Capture image from webcam Logitech
-
同一个问题不要问两次。
标签: c# webcam-capture logitech