Demo entry 6687440

ll

   

Submitted by anonymous on Dec 28, 2017 at 13:52
Language: C#. Code size: 1.7 kB.

IpCameraHelper ip;//添加摄像头方法
        //视频录制方法
        VideoFileWriter vide = new VideoFileWriter();
        //设置定时器
        DispatcherTimer time1 = new DispatcherTimer();   
   Action<ImageEventArgs> ac = (age) =>
            {
                //获取视频图像
                image.Source = age.FrameReadyEventArgs.BitmapImage;
                //建立图像流
                BitmapEncoder bit = new BmpBitmapEncoder();
                //将图像存储到图像流里
                bit.Frames.Add(BitmapFrame.Create(age.FrameReadyEventArgs.BitmapImage));
                //创建内存流
                MemoryStream memory = new MemoryStream();
                //指定图像编码
                bit.Save(memory);
                //创建位图
                Bitmap map = new Bitmap(memory);
                if (vide.IsOpen)
                {
                    //录制
                    vide.WriteVideoFrame(map);
                }
            };
            //调取设置中的IP地址、用户及密码,并成像
            ip = new IpCameraHelper(Properties.Settings.Default.IP,
                Properties.Settings.Default.Name, Properties.Settings.Default.Pwd, ac);
            time1.Interval += new TimeSpan(0, 1,0);
            time1.Tick += lujin;
            time1.Start();//定时器开启
            ip.StartProcessing();//打开摄像头
        }
        public void lujin(object sender, EventArgs e)
        {
            //获取系统时间
            DateTime da = DateTime.Now;
            //设置文件保存路径
            string str = String.Format(@"C:\Users\yinhonghui\Desktop\小区智能安保系统\
           视频存储文件\{0}{1}{2}{3}{4}{5}.avi", da.Year, da.Month, da.Day, da.Hour, da.Minute, da.Second);
            vide.Open(str, 640, 480, 25, VideoCodec.MPEG4);
        }

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).