智能家居视频监控系统_第1页
智能家居视频监控系统_第2页
智能家居视频监控系统_第3页
智能家居视频监控系统_第4页
智能家居视频监控系统_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、智能家居视频监控系统简介:本系统采用了360度无死角摄像头,可全方位监控自己的住所,并且可以锁定监控,例如门外。监控系统可在pc端查看记录,并且可以设定场景锁定,若场景发生变化,便会触发报警系统,给设定的邮箱或手机发送邮件及短信提醒,实时告知用户紧急状况。此系统可以进行远程监控,即用户可以不在家里的pc端进行监控,只要用户可以上网,就可通过与被控端连接的计算机外网ip地址监控住所的一切动向。这让监控变得简洁化及随身化。代码:1.Login.csusing System;using System.Collections.Generic;using System.ComponentModel;us

2、ing System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;/添加的命名空间using System.Data.OleDb;using VWMS.CommonClass;namespace VWMS public partial class frmLogin : Form public frmLogin() InitializeComponent(); DataCon datacon = new DataCon(); DataOperate dataoperate = new DataOpe

3、rate(); private void btnLogin_Click(object sender, EventArgs e) if (txtName.Text = ) errorProName.SetError(txtName, 用户名不能为空!); else errorProName.Clear(); string strSql = select * from tb_admin where name= + txtName.Text + and pwd= + txtPwd.Text + ; DataSet ds = dataoperate.getDs(strSql, tb_admin); i

4、f (ds.Tables0.Rows.Count 0) this.Hide(); frmMain frmmain = new frmMain(); frmmain.Show(); else MessageBox.Show(用户名或密码错误!, 警告, MessageBoxButtons.OK, MessageBoxIcon.Warning); private void btnExit_Click(object sender, EventArgs e) Application.Exit(); private void txtName_KeyPress(object sender, KeyPres

5、sEventArgs e) if (e.KeyChar = 13) txtPwd.Focus(); e.Handled = true; private void txtPwd_KeyPress(object sender, KeyPressEventArgs e) if (e.KeyChar = 13) btnLogin.Focus(); e.Handled = true; private void frmLogin_Load(object sender, EventArgs e) SetMonitor.csusing System;using System.Collections.Gener

6、ic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.OleDb;using VWMS.CommonClass;namespace VWMS public partial class frmSetMonitor : Form public frmSetMonitor() InitializeComponent(); DataOperate dataoperate = new DataO

7、perate(); DataSet ds; private void frmSetMonitor_Load(object sender, EventArgs e) lviewBind(); private void btnAdd_Click(object sender, EventArgs e) if (txtName.Text = string.Empty) MessageBox.Show(用户名不能为空!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else ds = dataoperate.getDs(select *

8、from tb_admin where name= + txtName.Text + , tb_admin); if (ds.Tables0.Rows.Count 0) MessageBox.Show(该用户已经存在!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else dataoperate.getCom(insert into tb_admin (name,pwd) values( + txtName.Text + , + txtPwd.Text + ); lviewBind(); txtName.Text = txtP

9、wd.Text = string.Empty; private void btnEdit_Click(object sender, EventArgs e) if (txtName.Text = string.Empty & txtPwd.Text = string.Empty) MessageBox.Show(用户名或密码不能为空!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else dataoperate.getCom(update tb_admin set pwd = + txtPwd.Text + where nam

10、e= + txtName.Text + ); lviewBind(); txtName.Text = txtPwd.Text = string.Empty; private void btnDel_Click(object sender, EventArgs e) if (txtName.Text.ToLower() = tsoft) MessageBox.Show(该用户是超级用户,不能删除!, 警告, MessageBoxButtons.OK, MessageBoxIcon.Warning); else dataoperate.getCom(delete from tb_admin whe

11、re name= + txtName.Text + ); lviewBind(); txtName.Text = lview.Items0.Text; private void lview_Click(object sender, EventArgs e) txtName.Text = lview.SelectedItems0.Text; txtPwd.Text = string.Empty; public void lviewBind() lview.Items.Clear(); ds = dataoperate.getDs(select name from tb_admin, tb_adm

12、in); foreach (DataRow dr in ds.Tables0.Rows) ListViewItem lvItem = new ListViewItem(dr0.ToString(), 0); lvItem.SubItems.Add(dr0.ToString(); lview.Items.Add(lvItem); Register.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using Syste

13、m.Text;using System.Windows.Forms;using VWMS.CommonClass;using Microsoft.Win32;namespace VWMS public partial class frmRegister : Form public frmRegister() InitializeComponent(); SoftReg softreg = new SoftReg(); private void frmRegister_Load(object sender, EventArgs e) txtMNum.Text = softreg.getMNum(

14、); private void btnReg_Click(object sender, EventArgs e) if (txtRNum.Text.Equals(softreg.getRNum() RegistryKey retkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(software, true).CreateSubKey(wxk).CreateSubKey(wxk.INI).CreateSubKey(txtRNum.Text); retkey.SetValue(UserName, tsoft); MessageBox.Sho

15、w(注册成功!, 信息, MessageBoxButtons.OK, MessageBoxIcon.Information); showMain(); else MessageBox.Show(注册码输入错误!, 错误, MessageBoxButtons.OK, MessageBoxIcon.Error); private void btnClose_Click(object sender, EventArgs e) showMain(); /隐藏注册窗体,显示主窗体 public void showMain() this.Hide(); frmMain frmmain = new frmM

16、ain(); frmmain.Show(); Play.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace VWMS public partial class frmPlay : Form public frmPlay() InitializeComponent(); private void btnPlay_

17、Click(object sender, EventArgs e) ofDialog.Filter = *.avi|*.avi; ofDialog.Title = 选择视频文件; ofDialog.InitialDirectory = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().LastIndexOf() + Vid

18、eo; if (ofDialog.ShowDialog() = DialogResult.OK) this.axWindowsMediaPlayer1.URL = ofDialog.FileName; private void btnClose_Click(object sender, EventArgs e) this.Close(); private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e) Main.csusing System;using System.Collections.Generic;using S

19、ystem.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;/添加的命名空间using VWMS.CommonClass;using System.IO.Ports;using Microsoft.Win32;using System.Threading;namespace VWMS public partial class frmMain : Form public frmMain() InitializeComponent(); PelcoD

20、 pelcod = new PelcoD(); SoftReg softreg = new SoftReg(); SerialPort serialPort = new SerialPort(COM1, 2400, Parity.None, 8); int m_dwDevNum = 0; byte addressin = Byte.Parse(Convert.ToString(0 x01); byte speedin = Byte.Parse(Convert.ToString(0 xff); byte messagesend; private void frmMain_Load(object

21、sender, EventArgs e) plVideo1.BackgroundImage = null; RegistryKey retkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(software, true).CreateSubKey(wxk).CreateSubKey(wxk.INI); foreach (string strRNum in retkey.GetSubKeyNames() if (strRNum = softreg.getRNum() this.Text = 智能视频监控系统; btnReg.Enabled

22、= false; startMonitor(); return; this.Text = 智能视频监控系统; btnReg.Enabled = true; btnSetMonitor.Enabled = btnAutoMonitor.Enabled = false; startMonitor(); MessageBox.Show(您现在使用的是试用版,该软件可以免费试用30次!,提示, MessageBoxButtons.OK, MessageBoxIcon.Information); Int32 tLong; try tLong = (Int32)Registry.GetValue(HKEY

23、_LOCAL_MACHINESOFTWAREangel, UseTimes, 0); MessageBox.Show(感谢您已使用了 + tLong + 次, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch Registry.SetValue(HKEY_LOCAL_MACHINESOFTWAREangel, UseTimes, 0, RegistryValueKind.DWord); MessageBox.Show(欢迎新用户使用本软件, 提示, MessageBoxButtons.OK, MessageBoxIcon.

24、Information); tLong = (Int32)Registry.GetValue(HKEY_LOCAL_MACHINESOFTWAREangel, UseTimes, 0); if (tLong 30) int Times = tLong + 1; Registry.SetValue(HKEY_LOCAL_MACHINESOFTWAREangel, UseTimes, Times); else MessageBox.Show(试用次数已到, 警告, MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit();

25、private void frmMain_Move(object sender, EventArgs e) for (int i = 0; i m_dwDevNum; i+) plVideo1.Invalidate(); VideoOperate.VCAUpdateOverlayWnd(this.Handle); VideoOperate.VCAUpdateVideoPreview(i, plVideo1.Handle); private void btnSetMonitor_Click(object sender, EventArgs e) frmSetMonitor frmsetmonit

26、or = new frmSetMonitor(); frmsetmonitor.ShowDialog(); private void btnVideo_Click(object sender, EventArgs e) if (btnVideo.Text = 录像) sfDialog.Filter = *.avi|*.avi; sfDialog.Title = 保存视频文件; sfDialog.InitialDirectory = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().Substri

27、ng(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().LastIndexOf() + Video; if (sfDialog.ShowDialog() = DialogResult.OK) btnVideo.Text = 停止录像; VideoOperate.VCASetKeyFrmInterval(0, 250); VideoOperate.VCASetBitRate(0, 256); VideoOperate.VCASetVidCapFrameRate(0, 25, false);

28、VideoOperate.VCASetVidCapSize(0, 320, 240); VideoOperate.VCASetXVIDQuality(0, 10, 3); VideoOperate.VCASetXVIDCompressMode(0, VideoOperate.COMPRESSMODE.XVID_VBR_MODE); VideoOperate.VCAStartVideoCapture(0, VideoOperate.CAPMODEL.CAP_MPEG4_STREAM, VideoOperate.MP4MODEL.MPEG4_AVIFILE_CALLBACK, sfDialog.F

29、ileName); else if (btnVideo.Text = 停止录像) btnVideo.Text = 录像; VideoOperate.VCAStopVideoCapture(0); /回放 private void btnPlay_Click(object sender, EventArgs e) frmPlay frmpaly = new frmPlay(); frmpaly.ShowDialog(); /快照 private void btnSnapShots_Click(object sender, EventArgs e) if (rbtnBMP.Checked) Vid

30、eoOperate.VCASaveAsBmpFile(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().LastIndexOf() + Photo + DateTime.Now.ToFileTime() + .bmp); else VideoOperate.VCASaveAsJpegFile(0, Applicati

31、on.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf().LastIndexOf() + Photo + DateTime.Now.ToFileTime() + .jpg, 100); /开始自动监控 private void btnAutoMonitor_Click(object sender, EventArgs e) if (btnAutoM

32、onitor.Text = 开始) if (rbtnWideWatch.Checked) messagesend = pelcod.CameraTilt(addressin, PelcoD.Tilt.Up, speedin); serialPort.Open(); serialPort.Write(messagesend, 0, 7); serialPort.Close(); Thread.Sleep(2000); messagesend = pelcod.CameraPan(addressin, PelcoD.Pan.Left, speedin); serialPort.Open(); se

33、rialPort.Write(messagesend, 0, 7); serialPort.Close(); Thread.Sleep(2000); messagesend = pelcod.CameraTilt(addressin, PelcoD.Tilt.Down, speedin); serialPort.Open(); serialPort.Write(messagesend, 0, 7); serialPort.Close(); Thread.Sleep(2000); messagesend = pelcod.CameraPan(addressin, PelcoD.Pan.Right

34、, speedin); serialPort.Open(); serialPort.Write(messagesend, 0, 7); serialPort.Close(); else if (rbtnVerticalWatch.Checked) messagesend = pelcod.CameraTilt(addressin, PelcoD.Tilt.Up, speedin); serialPort.Open(); serialPort.Write(messagesend, 0, 7); serialPort.Close(); Thread.Sleep(2000); messagesend

35、 = pelcod.CameraTilt(addressin, PelcoD.Tilt.Down, speedin); serialPort.Open(); serialPort.Write(messagesend, 0, 7); serialPort.Close(); else messagesend = pelcod.CameraPan(addressin, PelcoD.Pan.Left, speedin); serialPort.Open(); serialPort.Write(messagesend, 0, 7); serialPort.Close(); Thread.Sleep(2

36、000); messagesend = pelcod.CameraPan(addressin, PelcoD.Pan.Right, speedin); serialPort.Open(); serialPort.Write(messagesend, 0, 7); serialPort.Close(); btnAutoMonitor.Text = 停止; else stopMove(); btnAutoMonitor.Text = 开始; /停止监控 private void btnStop_Click(object sender, EventArgs e) if (btnStop.Text =

37、 停止) string strDPath = Application.StartupPath; string strPath = strDPath.Substring(0, strDPath.LastIndexOf().Substring(0, strDPath.Substring(0, strDPath.LastIndexOf().LastIndexOf() + Image主页面主界面图片.bmp; plVideo1.BackgroundImage = System.Drawing.Image.FromFile(strPath); VideoOperate.VCAUnInitSdk(); b

38、tnStop.Text = 开始; else if (btnStop.Text = 开始) plVideo1.BackgroundImage = null; startMonitor(); btnStop.Text = 停止; /打开软件注册窗体 private void btnReg_Click(object sender, EventArgs e) frmRegister frmregister = new frmRegister(); frmregister.Show(); this.Hide(); #region 释放鼠标时,视频监控停止移动 private void btnUp_Mo

39、useUp(object sender, MouseEventArgs e) stopMove(); private void btnDown_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnLeft_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnRight_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnAHighlghts

40、_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnCHighlghts_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnAFocus_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnCFocus_MouseUp(object sender, MouseEventArgs e) stopMove(); private void b

41、tnAAperture_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnCAperture_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnAWipers_MouseUp(object sender, MouseEventArgs e) stopMove(); private void btnCWipers_MouseUp(object sender, MouseEventArgs e) stopMove(); #e

42、ndregion /关闭主窗体时,退出应用程序 private void frmMain_FormClosing(object sender, FormClosingEventArgs e) Application.Exit(); /开始监控 protected void startMonitor() if (VideoOperate.VCAInitSdk(this.Handle, VideoOperate.DISPLAYTRANSTYPE.PCI_MEMORY_VIDEOMEMORY, false) m_dwDevNum = VideoOperate.VCAGetDevNum(); if (

43、m_dwDevNum = 0) MessageBox.Show(VC404卡驱动程序没有安装); else for (int i = 0; i m_dwDevNum; i+) VideoOperate.VCAOpenDevice(i, plVideo1.Handle); VideoOperate.VCAStartVideoPreview(i); /停止移动 protected void stopMove() messagesend = pelcod.CameraStop(addressin); serialPort.Open(); serialPort.Write(messagesend, 0

44、, 7); serialPort.Close(); private void plVideo1_Paint(object sender, PaintEventArgs e) Program.csusing System;using System.Collections.Generic;using System.Windows.Forms;namespace VWMS static class Program / / 应用程序的主入口点。 / STAThread static void Main() Application.EnableVisualStyles(); Application.Se

45、tCompatibleTextRenderingDefault(false); Application.Run(new frmLogin(); DataCon.csusing System;using System.Collections.Generic;using System.Text;using System.Data;using System.Data.OleDb;using System.Windows.Forms;namespace VWMS.CommonClass class DataCon public OleDbConnection getCon() string strDP

46、ath = Application.StartupPath; string strDataSource = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + strDPath.Substring(0, strDPath.LastIndexOf().Substring(0, strDPath.Substring(0, strDPath.LastIndexOf().LastIndexOf() + DataBasedb_VWMS.mdb; OleDbConnection oledbCon = new OleDbConnection(strDataSour

47、ce); return oledbCon; DataOperate.csusing System;using System.Collections.Generic;using System.Text;using System.Data;using System.Data.OleDb;namespace VWMS.CommonClass class DataOperate DataCon datacon = new DataCon(); OleDbConnection oledbcon; OleDbCommand oledbcom; OleDbDataAdapter oledbda; DataS

48、et ds; public void getCom(string strCon) oledbcon = datacon.getCon(); oledbcom = new OleDbCommand(strCon, oledbcon); oledbcon.Open(); oledbcom.ExecuteNonQuery(); oledbcon.Close(); public DataSet getDs(string strCon, string tbname) oledbcon = datacon.getCon(); oledbda = new OleDbDataAdapter(strCon, o

49、ledbcon); ds = new DataSet(); oledbda.Fill(ds, tbname); return ds; PelcoD.csusing System;using System.Collections.Generic;using System.Text;using System.Collections;namespace VWMS.CommonClass class PelcoD private string watchdir = ;/监控方向 private static readonly byte STX = 0 xFF;/同步字节 #region 监控方向和定时

50、监控实体 public string WatchDir get return watchdir; set watchdir = value; #endregion #region 基本指令定义 #region 指令码1 private const byte FocusNear = 0 x01;/增加聚焦 private const byte IrisOpen = 0 x02;/减小光圈 private const byte IrisClose = 0 x04;/增加光圈 private const byte CameraOnOff = 0 x08;/摄像机打开和关闭 private const

51、 byte AutoManualScan = 0 x10;/自动和手动扫描 private const byte Sense = 0 x80;/Sence码 #endregion #region 指令码2 private const byte PanRight = 0 x02;/右 private const byte PanLeft = 0 x04;/左 private const byte TiltUp = 0 x08;/上 private const byte TiltDown = 0 x10;/下 private const byte ZoomTele = 0 x20;/增加对焦 pr

52、ivate const byte ZoomWide = 0 x40;/减小对焦 private const byte FocusFar = 0 x80;/减小聚焦 #endregion #region 镜头左右平移的速度 private const byte PanSpeedMin = 0 x00;/停止 private const byte PanSpeedMax = 0 xFF;/最高速 #endregion #region 镜头上下移动的速度 private const byte TiltSpeedMin = 0 x00;/停止 private const byte TiltSpeedM

53、ax = 0 x3F;/最高速 #endregion #endregion #region 云台控制枚举 public enum Switch On = 0 x01, Off = 0 x02 /雨刷控制 public enum Focus Near = FocusNear, Far = FocusFar /聚焦控制 public enum Zoom Wide = ZoomWide, Tele = ZoomTele /对焦控制 public enum Tilt Up = TiltUp, Down = TiltDown /上下控制 public enum Pan Left = PanLeft, R

54、ight = PanRight /左右控制 public enum Scan Auto, Manual /自动和手动控制 public enum Iris Open = IrisOpen, Close = IrisClose /光圈控制 #endregion #region 云台控制方法 /雨刷控制 public byte CameraSwitch(uint deviceAddress, Switch action) byte m_action = CameraOnOff; if (action = Switch.On) m_action = CameraOnOff + Sense; retu

55、rn Message.GetMessage(deviceAddress, m_action, 0 x00, 0 x00, 0 x00); /光圈控制 public byte CameraIrisSwitch(uint deviceAddress, Iris action) return Message.GetMessage(deviceAddress, (byte)action, 0 x00, 0 x00, 0 x00); /聚焦控制 public byte CameraFocus(uint deviceAddress, Focus action) if (action = Focus.Nea

56、r) return Message.GetMessage(deviceAddress, (byte)action, 0 x00, 0 x00, 0 x00); else return Message.GetMessage(deviceAddress, 0 x00, (byte)action, 0 x00, 0 x00); /对焦控制 public byte CameraZoom(uint deviceAddress, Zoom action) return Message.GetMessage(deviceAddress, 0 x00, (byte)action, 0 x00, 0 x00);

57、 /上下控制 public byte CameraTilt(uint deviceAddress, Tilt action, uint speed) if (speed TiltSpeedMin) speed = TiltSpeedMin; if (speed TiltSpeedMax) speed = TiltSpeedMax; return Message.GetMessage(deviceAddress, 0 x00, (byte)action, 0 x00, (byte)speed); /左右控制 public byte CameraPan(uint deviceAddress, Pa

58、n action, uint speed) if (speed PanSpeedMin) speed = PanSpeedMin; if (speed PanSpeedMax) speed = PanSpeedMax; return Message.GetMessage(deviceAddress, 0 x00, (byte)action, (byte)speed, 0 x00); /停止云台的移动 public byte CameraStop(uint deviceAddress) return Message.GetMessage(deviceAddress, 0 x00, 0 x00,

59、0 x00, 0 x00); /自动和手动控制 public byte CameraScan(uint deviceAddress, Scan scan) byte m_byte = AutoManualScan; if (scan = Scan.Auto) m_byte = AutoManualScan + Sense; return Message.GetMessage(deviceAddress, m_byte, 0 x00, 0 x00, 0 x00); #endregion public struct Message public static byte Address; publi

60、c static byte CheckSum; public static byte Command1, Command2, Data1, Data2; public static byte GetMessage(uint address, byte command1, byte command2, byte data1, byte data2) if (address 256) throw new Exception(Pelco D协议只支持256设备); Address = Byte.Parse(address).ToString(); Data1 = data1; Data2 = dat

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论