Connect to IP Camera Using Emgu CV's Capture = New Capture()

久未见 提交于 2019-12-23 03:10:07

问题


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().

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

Is it possible to do this using Capture = New Capture? If not, is their any other method?

Thanks.


回答1:


This is the solution I used in the end. It only works with JPEG webcams (not MJPEG) and does not require 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
    '-----------------------------------------------------------------------------------------



回答2:


This camera has ip username and password? if you try something like this:

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


来源:https://stackoverflow.com/questions/15934961/connect-to-ip-camera-using-emgu-cvs-capture-new-capture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!