I create a Image capture program using Aforge library. this is a very basic program. when click of a button web camera activated and show image in to Picture box in c# windows application. it developed on .net 4.8. my program works on Windows 10 operating system but i can't run this on windows 11 OS. when click Enable Camera Button on win 11, it does not show anything to Pic Box.
`using System;
using System;
using System.Drawing;
using System.Windows.Forms;
using AForge.Video;
using AForge.Video.DirectShow;
namespace CameraProject
{
public partial class Form1 : Form
{
private FilterInfoCollection filterinfocollecton;
private VideoCaptureDevice videocapturedevice;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
filterinfocollecton = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (filterinfocollecton.Count == 0)
{
MessageBox.Show("No web camera found.");
return;
}
videocapturedevice = new VideoCaptureDevice(filterinfocollecton[0].MonikerString);
foreach (FilterInfo filterInfo in filterinfocollecton)
{
cmbCamera.Items.Add(filterInfo.Name);
}
videocapturedevice = new VideoCaptureDevice();
cmbCamera.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e)
{
videocapturedevice = new VideoCaptureDevice(filterinfocollecton[cmbCamera.SelectedIndex].MonikerString);
videocapturedevice.NewFrame += Videocapturedevice_NewFrame;
videocapturedevice.Start();
}
private void Videocapturedevice_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
picBox.Image = (Bitmap)eventArgs.Frame.Clone();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (videocapturedevice != null && videocapturedevice.IsRunning)
{
videocapturedevice.SignalToStop();
videocapturedevice.WaitForStop();
}
}
}
}