vb.net 使用 Emgu CV 的 Capture = New Capture() 连接到 IP 摄像机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15934961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connect to IP Camera Using Emgu CV's Capture = New Capture()
提问by Smaointe
Using Visual Basic 2008 and Emgu CV, I can capture the stream of a webcam on my PC. What I want to do is connect to an IP camera, knowing its URL, using Capture = New Capture().
使用 Visual Basic 2008 和 Emgu CV,我可以在我的 PC 上捕获网络摄像头的流。我想要做的是连接到 IP 摄像机,知道它的 URL,使用 Capture = New Capture()。
Here is the code I have:
这是我的代码:
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
I get the following error: Unable to create capture from rtsp://[IP Address]/mpeg4/media.amp
我收到以下错误:无法从 rtsp://[IP 地址]/mpeg4/media.amp 创建捕获
Is it possible to do this using Capture = New Capture? If not, is their any other method?
是否可以使用 Capture = New Capture 来做到这一点?如果没有,他们还有其他方法吗?
Thanks.
谢谢。
采纳答案by Smaointe
This is the solution I used in the end. It only works with JPEG webcams (not MJPEG) and does not require EmguCV
这是我最后使用的解决方案。它只适用于 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
'-----------------------------------------------------------------------------------------
回答by Rafael Souza
This camera has ip username and password? if you try something like this:
这个摄像头有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

