visual C# 2010 express
.net framework 4.0
2.使用IPCAM廠牌
AVTECH AVN813
3.建立windows form project
建立projectau->選擇windows form
toolbox內拉出picturebox(預設名字為pictureBox1)
toolbox內拉出timer->property->
enable選為true
interval time 是每次截取的時間,可依fps自行修改
4.emample code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; //一定要有 bitmap格式要用到
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace testIPcam
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
//ipcam URL
string sourceURL ="http://192.168.1.10:88/cgi-bin/guest/Video.cgi?media=JPEG";
// create HTTP request
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
//add id,password
req.Credentials = new NetworkCredential("admin", "admin");
// get response
WebResponse resp = req.GetResponse();
// get response stream
Bitmap bmp = new Bitmap(resp.GetResponseStream());
//show image in picturebox
pictureBox1.Image = bmp;
}
}
}
請問如果 Bitmap bmp = new Bitmap(resp.GetResponseStream()); 這行出現參數無效,是甚麼原因呢?
回覆刪除