本文介绍了如何让网络摄像机流成C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用AForge库,使这个小程序,这显示了一个摄像头实时输入到一个PictureBox。

I've used AForge library to make this little program, that shows live feed from a webcam into a PictureBox.

private FilterInfoCollection VideoCaptureDevices;
private VideoCaptureDevice FinalVideoDevice;

private void Form1_Load(object sender, EventArgs e)
{
   VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
   try
   {
      foreach (FilterInfo VidCapDev in VideoCaptureDevices)
      {
         comboBox1.Items.Add(VidCapDev.Name);
         comboBox1.SelectedIndex = 0;
      }
      FinalVideoDevice = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
      FinalVideoDevice.NewFrame += new NewFrameEventHandler(FinalVideoDevice_NewFrame);
      FinalVideoDevice.Start();
   }
   catch
   {
      MessageBox.Show("No camera found. Please connect your camera and click RESET.");
   }
}

        //////////////////////////////////////////////////////////////////////////////////////////

void FinalVideoDevice_NewFrame(object sender, NewFrameEventArgs e)
{
   try
    {
       pictureBox1.Image = (Bitmap)e.Frame.Clone();
    }
    catch { }
}

但我也需要从IP摄像机获取流。任何想法将是最好的方式得到它?

But I also need to get a stream from an IP camera. Any ideas what would be the best way to get it?

谢谢!

推荐答案

从同一AForge.net解决了它与MJPEGStream:)

Solved it with MJPEGStream from the same AForge.net :)

MJPEGStream stream = new MJPEGStream("http://192.168.2.5:8080/videofeed");
            stream.NewFrame += new NewFrameEventHandler(video_NewFrame);
            stream.Start();

这篇关于如何让网络摄像机流成C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 02:25