如何用Aforge镜像捕捉网络摄像头.. Net库

本文关键字:网络 摄像头 Net 何用 Aforge 镜像 | 更新日期: 2023-09-27 18:11:37

我正在使用AForge。. NET库(http://www.aforgenet.com)从我的网络摄像头捕获图像,将其显示在图片框中,然后保存。但捕获不像镜子。有人知道如何在c#中镜像捕获吗?

 public static Bitmap _latestFrame;
private FilterInfoCollection webcam;
private VideoCaptureDevice cam;
Bitmap bitmap;
private int orderidcapture = 0;
private string date1 = "";

private void Frm_Capturet_Load(object sender, EventArgs e)
{

    try
    {
        piclocation = new Ini(Application.StartupPath + "''UserSetting.ini").GetValue("Webservice",
                                 "DigitalSign").ToString();

        webcam = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo VideoCaptureDevice in webcam)
        {
            comboBox1.Items.Add(VideoCaptureDevice.Name);
        }
        comboBox1.SelectedIndex = 0;
    }
    catch (Exception error)
    {
        MessageBox.Show(error.Message + "error11");
    }
    Focus();


}
private string piclocation = "";
void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
        bitmap = (Bitmap)eventArgs.Frame.Clone();
        picFrame.Image = bitmap;
}
private void button1_Click(object sender, EventArgs e)
{
    cam = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
    cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
    cam.DisplayPropertyPage(new IntPtr(0));
    cam.Start();
}

private void button2_Click(object sender, EventArgs e)
{

    date1 = date1.Replace("/", "");
    Bitmap current = (Bitmap)bitmap.Clone();
    string filepath = Environment.CurrentDirectory;
    string fileName = System.IO.Path.Combine(piclocation, orderidcapture + "__" + date1 + @"name.jpg");
    current.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
    current.Dispose();
    current = null;
}

如何用Aforge镜像捕捉网络摄像头.. Net库

我自己解决了这个问题。

  void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        try
        {
            bitmap = (Bitmap)eventArgs.Frame.Clone();
            ///add these two lines to mirror the image
            var filter = new Mirror(false, true);
            filter.ApplyInPlace(bitmap);
            ///
            picFrame.Image = bitmap;
        }
        catch
        {

        }
    }