我想从一个ip cam获得实时流...之后我想要从现场直播的图片....在vb.net

时间:2014-03-14 06:22:04

标签: c# vb.net vb.net-2010

进口AForge.Video

进口AForge.Video.VFW

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Try
        Dim Stream As AForge.Video.MJPEGStream = New AForge.Video.MJPEGStream("http://192.168.1.250/mjpeg.cgi")
        Stream.Login = ("admin")
        Stream.Password = ("admin")
        Stream.Start()

        Dim st As String = ""

    Catch ex As Exception
        MsgBox(ex.Message.ToString(), MsgBoxStyle.OkOnly, "Error")
        Exit Sub
    End Try
End Sub

结束班

这就是我到目前为止所做的...来开始流... 知道我想知道。  如何在图片框中显示此流?以及如何从这个流中获取图像。

1 个答案:

答案 0 :(得分:0)

MJEGStream包含事件。在类级别将您的Stream对象声明为

Private WithEvents Stream As AForge.Video.MJPEGStream

然后使用类似

的子句向MJPEGStream.NewFrame事件添加事件处理程序
Private Sub Handle_NewFrame(sender as Object, e as AForge.Video.NewFrameEventArgs)
   Picturebox1.Image = e.Frame
End Sub

像在代码中一样启动流。
别忘了初始化Source对象。

Source = New AForge.Video.MJPEGStream("http://192.168.1.250/mjpeg.cgi")

eventargs变量包含新帧作为图像,然后您可以在图片框中显示。 我和AForge合作已经有一段时间了,但它应该没问题。