以下是 參考c#範例 jkfixed 成vb.net 的 抓取ipcam 影像的範例
使用的是AXIS 牌子的 ipcam ,這牌子似乎是被認為best的ipcam之一
他的api確實清楚好用

參考
http://www.codeproject.com/KB/audio-video/cameraviewer.aspx
http://www.axis.com/techsup/cam_servers/dev/cam_http_api_2.php

'========================

Imports System.Web
Imports System.Net
Imports System.IO
Public Class Form1
Dim ii = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'// create HTTP request

Dim sourceURL = "http://141.117.159.36/axis-cgi/jpg/image.cgi?resolution=320x240&camera=1&compression=25&text=0&clock=0&date=0"
Dim req As HttpWebRequest = WebRequest.Create(sourceURL)
'// set login and password

req.Credentials = New NetworkCredential("root", "pass")

Dim resp As WebResponse = req.GetResponse()
'// get response stream

Dim stream As Stream = resp.GetResponseStream()
Dim read As Integer = 0
Dim buffer(400000) As Byte '400KB 暫存區
Dim total As Integer = 0


Do '回傳這次讀取了多少個 最多1000 個byte
read = stream.Read(buffer, total, 1000)
If (read <> 0) Then
total += read '累計總量
End If

Loop While (read <> 0)

'// get bitmap
Dim bmp As Bitmap = Bitmap.FromStream(New MemoryStream(buffer, 0, total))

PictureBox1.Image = bmp


ii = ii + 1
bmp.Save("Pic/IPcam_" + ii.ToString + ".bmp", Imaging.ImageFormat.Bmp) '轉存jpeg格式


End Sub
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 prague12 的頭像
    prague12

    prague12

    prague12 發表在 痞客邦 留言(3) 人氣()