C# 实时网络摄像头和从网络摄像头捕获帧
此代码用于打开我的网络摄像头,此代码工作正常。我想添加一个小代码部分,将实时视频转换为灰度视频,如果有人知道算法,请帮助我这样做。试试这个你想以某种方式保存灰度视频吗?@Adrian hey我引用了你的链接,这非常有助于我改进我的应用程序,我非常感激,但我没有将实时视频帧转换为灰度。@PepitoSh不,我不想保存它。重要的部分是从网络摄像头实时获取灰度(黑白)视频。上面的代码工作正常,我需要得到灰度帧而不是原始帧(RGB)。C# 实时网络摄像头和从网络摄像头捕获帧,c#,aforge,webcam-capture,C#,Aforge,Webcam Capture,此代码用于打开我的网络摄像头,此代码工作正常。我想添加一个小代码部分,将实时视频转换为灰度视频,如果有人知道算法,请帮助我这样做。试试这个你想以某种方式保存灰度视频吗?@Adrian hey我引用了你的链接,这非常有助于我改进我的应用程序,我非常感激,但我没有将实时视频帧转换为灰度。@PepitoSh不,我不想保存它。重要的部分是从网络摄像头实时获取灰度(黑白)视频。上面的代码工作正常,我需要得到灰度帧而不是原始帧(RGB)。 using System; using System.Collect
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 AForge;
using AForge.Video;
using AForge.Video.DirectShow;
namespace Sample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private FilterInfoCollection CaptureDevice;
private VideoCaptureDevice FinalFrame;
private void Form1_Load(object sender, EventArgs e)
{
CaptureDevice = new FilterInfoCollection(FilterCategory.AudioCompressorCategory);
foreach (FilterInfo Device in CaptureDevice)
{
comboBox1.Items.Add(Device.Name);
}
comboBox1.SelectedIndex = 0;
FinalFrame = new VideoCaptureDevice();
}
private void button1_Click(object sender, EventArgs e)
{
FinalFrame = new VideoCaptureDevice(CaptureDevice[comboBox1.SelectedIndex].MonikerString);
FinalFrame.NewFrame+= new NewFrameEventHandler (FinalFrame_NewFrame);
FinalFrame.Start();
}
private void FinalFrame_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
}
}
}