繁体   English   中英

如何使用C#中的Aforge.Net库镜像网络摄像头的捕获

[英]how to mirror capture of webcam with Aforge.Net library in C#

我正在使用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;

}

我自己解决了这个问题。

  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
        {


        }

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM