资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
文档供参考,可复制、编制,期待您的好评与关注! 本实例实现超市摄像头定时监控系统。运行本例后,在“定时监控设置”处设置监控的星期及时间,单击【保存】按钮,将“定时设置”参数数据保存到数据库中。系统在运行到定时时间后,程序将自动进行监控。如图所示。另外,监控的录像文件和图片文件保存在D盘根目录中,命名格式为系统当前日期。图 超市摄像头定时监控实现过程(1)新建一个项目,命名为Ex13_10,默认窗体为Form1,添加一个类文件(.CS),用于编写视频类。(2)在Form1窗体中,主要添加一个PictrueBox控件,用于显示视频。(3)主要程序代码。视频类中主要程序代码如下: / / 开始录像 / / 要保存录像的路径 public void StarKinescope(string path) IntPtr hBmp = Marshal.StringToHGlobalAnsi(path); SendMessage(hWndC,WM_CAP_FILE_SET_CAPTURE_FILEA,0, hBmp.ToInt32(); SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0); / / 停止录像 / public void StopKinescope() SendMessage(hWndC, WM_CAP_STOP, 0, 0); Form1窗体主要代码如下: private void timer1_Tick(object sender, EventArgs e) string strTime=; /星期一 if (chk1.Checked & Convert.ToInt32(DateTime.Now.DayOfWeek)=1) strTime = DateTime.Now.ToString(HH:mm); DateTime date = Convert.ToDateTime(mtxt1.Text); if (strTime = date.ToString(HH:mm) video.StarKinescope(d: + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + .avi); /星期二 if (chk1.Checked & Convert.ToInt32(DateTime.Now.DayOfWeek) = 2) strTime = DateTime.Now.ToString(HH:mm); DateTime date = Convert.ToDateTime(mtxt2.Text); if (strTime = date.ToString(HH:mm) video.StarKinescope(d: + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + .avi); /星期三 if (chk1.Checked & Convert.ToInt32(DateTime.Now.DayOfWeek) = 3) strTime = DateTime.Now.ToString(HH:mm); DateTime date = Convert.ToDateTime(mtxt3.Text); if (strTime = date.ToString(HH:mm) video.StarKinescope(d: + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + .avi); /星期四 if (chk1.Checked & Convert.ToInt32(DateTime.Now.DayOfWeek) = 4) strTime = DateTime.Now.ToString(HH:mm); DateTime date = Convert.ToDateTime(mtxt4.Text); if (strTime = date.ToString(HH:mm) video.StarKinescope(d: + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + .avi); /星期五 if (chk1.Checked & Convert.ToInt32(DateTime.Now.DayOfWeek) = 5) strTime = DateTime.Now.ToString(HH:mm); DateTime date = Convert.ToDateTime(mtxt5.Text); if (strTime = date.ToString(HH:mm) video.StarKinescope(d: + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + .avi); /星期六 if (chk1.Checked & Convert.ToInt32(DateTime.Now.DayOfWeek) = 6) strTime = DateTime.Now.ToString(HH:mm); DateTime date = Convert.ToDateTime(mtxt6.Text); if (strTime = date.ToString(HH:mm) video.StarKinescope(d: + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + .avi); /星期日 if (chk1.Checked & Convert.ToInt32(DateTime.Now.DayOfWeek) = 7) strTime = DateTime.Now.ToString(HH:mm); DateTime date = Convert.ToDateTime(mtxt7.Text); if (strTime = date.ToString(HH:mm) video.StarKinescope(d: + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + .avi); /
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号