1

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.

Smaointe
  • 111
  • 1
  • 2
  • 12
  • Hmm those IP cameras, isn't it more a website where you have to click through some parts, in order to get the picture? So mpeg4/media.amp gives you a stream? Maybe you can start with an address that gives a static picture, and then pull a new picture more and more frequent, as first dirty workaround – Amegon Apr 10 '13 at 20:51

2 Answers2

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
    '-----------------------------------------------------------------------------------------
Smaointe
  • 111
  • 1
  • 2
  • 12
0

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
Rafael Souza
  • 27
  • 10