使用Visual Basic 2008和Emgu CV,我可以在PC上捕获网络摄像头流。 我想要做的是使用Capture = New Capture()连接到IP相机,知道其URL。
这是我的代码:
Imports Emgu.CV
Imports Emgu.CV.Util
Imports Emgu.CV.Structure
Public Class Form1
Dim capturez As Capture = New Capture("rtsp://[IP Address]/mpeg4/media.amp")
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim imagez As Image(Of Bgr, Byte) = capturez.QueryFrame()
PictureBox1.Image = imagez.ToBitmap()
End Sub
End Class
我收到以下错误:无法从rtsp创建捕获:// [IP地址] /mpeg4/media.amp
使用Capture = New Capture可以做到这一点吗?如果没有,是他们的任何其他方法吗?
感谢。
答案 0 :(得分:1)
这是我最后使用的解决方案。它仅适用于JPEG网络摄像头(不是MJPEG),不需要EmguCV
'Connect To Webcam ----------------------------------------------------------------------
Dim NumberFrames As Integer = 1
Dim imgNum = Convert.ToString(FrameNumber)
Dim sourceURL As String = ("http://91.142.238.200/record/current.jpg?rand=" + imgNum)
'create HTTP request
Dim req As HttpWebRequest = HttpWebRequest.Create(sourceURL)
'get response
Dim res As HttpWebResponse = req.GetResponse
'get response stream
Dim reader As New StreamReader(res.GetResponseStream())
'read data from stream
Dim img As Image = Image.FromStream(res.GetResponseStream())
'get bitmap
PictureBox1.Image = img
'Increment frame
FrameNumber = FrameNumber + 1
'-----------------------------------------------------------------------------------------
答案 1 :(得分:0)
这款相机有ip用户名和密码吗?如果你尝试这样的事情:
Imports Emgu.CV
Imports Emgu.CV.Util
Imports Emgu.CV.Structure
Public Class Form1
Dim capturez As Capture = New Capture("rtsp://username:password@[IP Address]/mpeg4/media.amp")
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim imagez As Image(Of Bgr, Byte) = capturez.QueryFrame()
PictureBox1.Image = imagez.ToBitmap()
End Sub
End Class