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

下载本文档

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

文档简介

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

2、.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 DataOperate(); pr

3、ivate 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 +

4、 "'" DataSet ds = dataoperate.getDs(strSql, "tb_admin"); if (ds.Tables0.Rows.Count > 0) this.Hide(); frmMain frmmain = new frmMain(); frmmain.Show(); else MessageBox.Show("用户名或密码错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); private void btn

5、Exit_Click(object sender, EventArgs e) Application.Exit(); private void txtName_KeyPress(object sender, KeyPressEventArgs 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;

6、private void frmLogin_Load(object sender, EventArgs e) 2. SetMonitor.csusing System;using System.Collections.Generic;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 pa

7、rtial class frmSetMonitor : Form public frmSetMonitor() InitializeComponent(); DataOperate dataoperate = new DataOperate(); DataSet ds; private void frmSetMonitor_Load(object sender, EventArgs e) lviewBind(); private void btnAdd_Click(object sender, EventArgs e) if (txtName.Text = string.Empty) Mess

8、ageBox.Show("用户名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); else ds = dataoperate.getDs("select * from tb_admin where name='" + txtName.Text + "'", "tb_admin"); if (ds.Tables0.Rows.Count > 0) MessageBox.Show("该用户已

9、经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); else dataoperate.getCom("insert into tb_admin (name,pwd) values('" + txtName.Text + "','" + txtPwd.Text + "')"); lviewBind(); txtName.Text = txtPwd.Text = string.Empty; privat

10、e 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 ='" + txt

11、Pwd.Text + "' where name='" + txtName.Text + "'"); lviewBind(); txtName.Text = txtPwd.Text = string.Empty; private void btnDel_Click(object sender, EventArgs e) if (txtName.Text.ToLower() = "tsoft") MessageBox.Show("该用户是超级用户,不能删除!", "警告",

12、 MessageBoxButtons.OK, MessageBoxIcon.Warning); else dataoperate.getCom("delete from tb_admin where name='" + txtName.Text + "'"); lviewBind(); txtName.Text = lview.Items0.Text; private void lview_Click(object sender, EventArgs e) txtName.Text = lview.SelectedItems0.Text;

13、 txtPwd.Text = string.Empty; public void lviewBind() lview.Items.Clear(); ds = dataoperate.getDs("select name from tb_admin", "tb_admin"); foreach (DataRow dr in ds.Tables0.Rows) ListViewItem lvItem = new ListViewItem(dr0.ToString(), 0); lvItem.SubItems.Add(dr0.ToString(); lview.

14、Items.Add(lvItem); 3. Register.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using VWMS.CommonClass;using Microsoft.Win32;namespace VWMS public partial class frmRegister : Form public fr

15、mRegister() InitializeComponent(); SoftReg softreg = new SoftReg(); private void frmRegister_Load(object sender, EventArgs e) txtMNum.Text = softreg.getMNum(); private void btnReg_Click(object sender, EventArgs e) if (txtRNum.Text.Equals(softreg.getRNum() RegistryKey retkey = Microsoft.Win32.Registr

16、y.CurrentUser.OpenSubKey("software", true).CreateSubKey("wxk").CreateSubKey("wxk.INI").CreateSubKey(txtRNum.Text); retkey.SetValue("UserName", "tsoft"); MessageBox.Show("注册成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Informati

17、on); 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 frmMain(); frmmain.Show(); 4. Play.csus

18、ing 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_Click(object sender, EventArgs e

19、) ofDialog.Filter = "*.avi|*.avi" ofDialog.Title = "选择视频文件" ofDialog.InitialDirectory = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("").Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("").LastI

20、ndexOf("") + "Video" 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) 5. Main.csusing System;

21、using System.Collections.Generic;using System.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

22、 frmMain() InitializeComponent(); PelcoD 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(0x01); byte speedin = Byte.Parse(Convert.ToString(0xff); b

23、yte messagesend; private void frmMain_Load(object 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.

24、GetSubKeyNames() if (strRNum = softreg.getRNum() this.Text = "智能视频监控系统" btnReg.Enabled = false; startMonitor(); return; this.Text = "智能视频监控系统" btnReg.Enabled = true; btnSetMonitor.Enabled = btnAutoMonitor.Enabled = false; startMonitor(); MessageBox.Show("您现在使用的是试用版,该软件可以免费试用

25、30次!","提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Int32 tLong; try tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINESOFTWAREangel", "UseTimes", 0); MessageBox.Show("感谢您已使用了" + tLong + "次", "提示", MessageBoxButtons.OK, Me

26、ssageBoxIcon.Information); catch Registry.SetValue("HKEY_LOCAL_MACHINESOFTWAREangel", "UseTimes", 0, RegistryValueKind.DWord); MessageBox.Show("欢迎新用户使用本软件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tLong = (Int32)Registry.GetValue("HKEY_LO

27、CAL_MACHINESOFTWAREangel", "UseTimes", 0); if (tLong < 30) int Times = tLong + 1; Registry.SetValue("HKEY_LOCAL_MACHINESOFTWAREangel", "UseTimes", Times); else MessageBox.Show("试用次数已到", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); App

28、lication.Exit(); 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) frm

29、SetMonitor frmsetmonitor = 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.Su

30、bstring(0, Application.StartupPath.LastIndexOf("").Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("").LastIndexOf("") + "Video" if (sfDialog.ShowDialog() = DialogResult.OK) btnVideo.Text = "停止录像" VideoOperate.VC

31、ASetKeyFrmInterval(0, 250); VideoOperate.VCASetBitRate(0, 256); VideoOperate.VCASetVidCapFrameRate(0, 25, false); VideoOperate.VCASetVidCapSize(0, 320, 240); VideoOperate.VCASetXVIDQuality(0, 10, 3); VideoOperate.VCASetXVIDCompressMode(0, VideoOperate.COMPRESSMODE.XVID_VBR_MODE); VideoOperate.VCASta

32、rtVideoCapture(0, VideoOperate.CAPMODEL.CAP_MPEG4_STREAM, VideoOperate.MP4MODEL.MPEG4_AVIFILE_CALLBACK, sfDialog.FileName); else if (btnVideo.Text = "停止录像") btnVideo.Text = "录像" VideoOperate.VCAStopVideoCapture(0); /回放 private void btnPlay_Click(object sender, EventArgs e) frmPla

33、y frmpaly = new frmPlay(); frmpaly.ShowDialog(); /快照 private void btnSnapShots_Click(object sender, EventArgs e) if (rbtnBMP.Checked) VideoOperate.VCASaveAsBmpFile(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("").Substring(0, Application.StartupPath.Substring

34、(0, Application.StartupPath.LastIndexOf("").LastIndexOf("") + "Photo" + DateTime.Now.ToFileTime() + ".bmp"); else VideoOperate.VCASaveAsJpegFile(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("").Substring(0, Application.

35、StartupPath.Substring(0, Application.StartupPath.LastIndexOf("").LastIndexOf("") + "Photo" + DateTime.Now.ToFileTime() + ".jpg", 100); /开始自动监控 private void btnAutoMonitor_Click(object sender, EventArgs e) if (btnAutoMonitor.Text = "开始") if (rbtnWideW

36、atch.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(); serialPort.Write(messagesend, 0,

37、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, speedin); serialPort.Open();

38、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 = pelcod.CameraTilt(addressin,

39、 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(2000); messagesend = pelcod.Came

40、raPan(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 = "停止

41、") 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

42、.FromFile(strPath); VideoOperate.VCAUnInitSdk(); btnStop.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_MouseUp(object sender, MouseEventArgs e) s

温馨提示

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

评论

0/150

提交评论