Exemplo n.º 1
0
		// 匹配摄像头
		public bool CheckCamera(Camera camera)
		{
			foreach (Camera c in cameras)
			{
				if ((camera.Name == c.Name) && ((camera.ID == 0) || (camera.ID != c.ID)))
					return false;
			}
			return true;
		}
Exemplo n.º 2
0
        // 新增camera,开始跑视频
		public bool Add(Camera camera)
		{
			// 创建视频源
			if (camera.CreateVideoSource())
			{
				// 增加到pool中
				InnerList.Add(camera);
				camera.Start();
				return true;
			}
			return false;
		}
Exemplo n.º 3
0
		// 从集中移除Camera,信号关闭。
		public void Remove(Camera camera)
		{
            try                          //页面视频个数及位置需要从新排列
            { 
                camera.SignalToStop();
            }
            catch (Exception )
            {
            
            }
            
			InnerList.Remove(camera);

            // 信号关闭
			
		}
Exemplo n.º 4
0
 /// <summary>
 /// 拍照函数
 /// </summary>
 public void snapshot(Camera camera)
 {
     concam = camera;
     bangding();
     string controlURL = string.Format("{0}/snapshot.cgi?", source);
     cgiReturn(controlURL);
 }
Exemplo n.º 5
0
 // 报警->邮件报警
 private void tsmi邮件报警_Click(object sender, EventArgs e)
 {
     cameraToEdit = multiplexer.LastClicked.Camera;
     if (cameraToEdit == null)
     {
         MessageBox.Show("你当前没有选中摄像头!");
     }
     else if (cameraToEdit.Provider.Name == "EasyN IP Camera")
     {
         报警邮件 youjian = new 报警邮件();
         youjian.CamCGI.ConCam = cameraToEdit;
         youjian.CamCGI.bangding();
         youjian.Show();
         youjian.TopMost = true;
     }
     else
     {
         MessageBox.Show("此功能只对 EasyN IP Camera 开放");
     }               
 }
Exemplo n.º 6
0
        // 从Xml中加载单个摄像头节点信息
        private void LoadCameras(XmlTextReader reader)
        {
            // 加载所有的摄像头信息节点
            while (reader.Name == "Camera")
            {
                int	depth = reader.Depth;

                // 创建新摄像头
                Camera camera = new Camera(reader.GetAttribute("name"));
                camera.ID			= int.Parse(reader.GetAttribute("id"));
                camera.Description	= reader.GetAttribute("desc");
                camera.Provider		= providers.GetProviderByName(reader.GetAttribute("视频源"));

                // 加载配置信息
                if (camera.Provider != null)
                {
                    camera.Configuration = camera.Provider.LoadConfiguration(reader);
                }

                // 把摄像头加到集合中
                cameras.Add(camera);

                if (camera.ID >= nextCameraID)
                {
                    nextCameraID = camera.ID + 1;
                }

                // 查询下一子节点
                reader.Read();

                // 移动到下一个节点
                while (reader.NodeType == XmlNodeType.EndElement)
                    reader.Read();
                if (reader.Depth < depth)
                    return;
            }
        }
Exemplo n.º 7
0
		// 把camera加到集合中
		public void Add(Camera camera)
		{
			InnerList.Add(camera);
		}
Exemplo n.º 8
0
		// 增加新摄像头
		public void Add(Camera camera)
		{
			Monitor.Enter(this);
			InnerList.Add(camera);
			Monitor.Exit(this);
		}
Exemplo n.º 9
0
        // 关闭摄像头
        private void CloseCamera()
        {
            cameraToEdit = multiplexer.LastClicked.Camera;
            if (cameraToEdit == null)
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }

            runningPool.Remove(cameraToEdit);       
            finalizationPool.Remove(cameraToEdit);
            multiplexer.LastClicked.Visible = false;
        }
Exemplo n.º 10
0
        // 打开摄像头
        private void OpenCamera()
        {
            cameraToEdit = multiplexer.LastClicked.Camera;
            if (cameraToEdit == null)
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }

            if (runningPool.Add(cameraToEdit))
            {
                multiplexer.CamerasVisible = true;
            }
        }
Exemplo n.º 11
0
        // 移除摄像头
        private void DeleteCamera()
        {
            cameraToEdit = multiplexer.LastClicked.Camera;
            if (cameraToEdit == null)
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }

            if (MessageBox.Show(this, "你确定要删除这个摄像头?", "警告",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                if (config.DeleteCamera(cameraToEdit))
                {
                    CloseCamera();
                    config.DeleteCamera(cameraToEdit);




                    multiplexer.LastClicked.Camera = null;
                }
                else
                {
                    MessageBox.Show(this, "删除失败~", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }

            }
        }
Exemplo n.º 12
0
        // 配置摄像头
        private void EditCamera()
        {
            cameraToEdit = multiplexer.LastClicked.Camera;
            if (cameraToEdit == null)
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }

            摄像头配置窗体 form = new 摄像头配置窗体();
            //设置提供商
            form.VideoProviders = config.providers;
            form.CheckCameraFunction = new CheckCameraHandler(CheckCamera);
            //设置摄像头
            form.Camera = cameraToEdit = multiplexer.LastClicked.Camera;

            //注册apply事件
            form.Apply += new EventHandler(editCamera_Apply);   
            if (form.ShowDialog() == DialogResult.OK)
            {
                runningPool.Remove(cameraToEdit);        //先把摄像头移除,以防前后两个同时存在。
                finalizationPool.Remove(cameraToEdit);
                cameraToEdit = form.Camera;
                OpenCamera();
            }
        }
Exemplo n.º 13
0
        // 增加摄像头
        private void AddCamera()
        {
            摄像头新增窗体 form = new 摄像头新增窗体();
            // 设置提供商
            form.VideoProviders = config.providers;
            // 设置回调函数,用于测试摄像头
            form.CheckCameraFunction = new CheckCameraHandler(CheckCamera);

            // 显示界面
            if (form.ShowDialog() == DialogResult.OK)
            {
                CountCamera++;      //统计已经添加的摄像头数
                Camera camera = form.Camera;
                config.AddCamera(camera);
                cameraToEdit = camera;
                switch (CountCamera)
                {
                    case 1:
                        View1.SetCamera(0, 0, camera.ID);
                        View2.SetCamera(0, 0, camera.ID);
                        View3.SetCamera(0, 0, camera.ID);
                        View4.SetCamera(0, 0, camera.ID);
                        View9.SetCamera(0, 0, camera.ID);
                        SelectedView = View1;
                        break;
                    case 2:
                        View2.SetCamera(0, 1, camera.ID);
                        View3.SetCamera(0, 1, camera.ID);
                        View4.SetCamera(0, 1, camera.ID);
                        View9.SetCamera(0, 1, camera.ID);
                        SelectedView = View2;
                        break;
                    case 3:
                        View3.SetCamera(0, 2, camera.ID);
                        View4.SetCamera(1, 0, camera.ID);
                        View9.SetCamera(0, 2, camera.ID);
                        SelectedView = View3;
                        break;
                    case 4:
                        View4.SetCamera(1, 1, camera.ID);
                        View9.SetCamera(1, 0, camera.ID);
                        SelectedView = View4;
                        break;
                    case 5:
                        View9.SetCamera(1, 1, camera.ID);
                        SelectedView = View9;
                        break;
                    case 6:
                        View9.SetCamera(1, 2, camera.ID);
                        SelectedView = View9;
                        break;
                    case 7:
                        View9.SetCamera(2, 0, camera.ID);
                        SelectedView = View9;
                        break;
                    case 8:
                        View9.SetCamera(2, 1, camera.ID);
                        SelectedView = View9;
                        break;
                    case 9:
                        View9.SetCamera(2, 2, camera.ID);
                        SelectedView = View9;
                        break;
                    default: break;
                }
                OpenView();
            }
        }
Exemplo n.º 14
0
        // 右键->关闭摄像头
        private void cmenu关闭摄像头_Click(object sender, EventArgs e)
        {
            cameraToEdit = multiplexer.LastClicked.Camera;
            if (cameraToEdit == null)
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }

            cameraToEdit = multiplexer.LastClicked.Camera;
            CloseCamera();
        }
Exemplo n.º 15
0
 // 右键->图像参数设置
 private void cmenu图像参数_Click(object sender, EventArgs e)
 {
     cameraToEdit = multiplexer.LastClicked.Camera;
     if (cameraToEdit == null)
     {
         MessageBox.Show("你当前没有选中摄像头!");
     }
     else if (cameraToEdit.Provider.Name == "EasyN IP Camera")
     {
         图像参数设置 Graph = new 图像参数设置();
         cameraToEdit = multiplexer.LastClicked.Camera;
         Graph.CamCGI.ConCam = cameraToEdit;
         Graph.CamCGI.bangding();
         Graph.Show();
     }
     else
     {
         MessageBox.Show("此功能只对 EasyN IP Camera 开放");
     }               
 }
Exemplo n.º 16
0
 // 设置摄像头在面板中位置
 public void SetCamera(int row, int col, Camera camera)
 {
     if ((row >= 0) && (col >= 0) && (row < MaxRows) && (col < MaxCols))
     {
         camWindows[row, col].Camera = camera;
     }
 }
Exemplo n.º 17
0
        // Apply the page
        public bool Apply()
        {
            string name = txt名字.Text.Replace('\\', ' ');

            if (checkCameraFunction != null)
            {
                Camera tmpCamera = new Camera(name);

                tmpCamera.ID = camera.ID;

                // check camera
                if (checkCameraFunction(tmpCamera) == false)
                {
                    Color tmp = this.txt名字.BackColor;

                    // highligh name edit box
                    this.txt名字.BackColor = Color.LightCoral;
                    // error message
                    MessageBox.Show(this, "此名字已被使用,请重新输入!", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    // restore & focus name edit box
                    this.txt名字.BackColor = tmp;
                    this.txt名字.Focus();

                    return false;
                }
            }

            // update camera name and description
            camera.Name = name;
            camera.Description = txt描述.Text;
            camera.Provider = providers[cb视频源.SelectedIndex - 1];

            return true;
        }
Exemplo n.º 18
0
        // 查看摄像头信息
        private void LookCamera()
        {
            cameraToEdit = multiplexer.LastClicked.Camera;
            if (cameraToEdit == null)
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }

            cameraInfo = new 摄像头信息();
            cameraInfo.Camera = cameraToEdit;
            cameraInfo.TopMost = config.fullScreen;
            cameraInfo.ShowDialog();

        }
Exemplo n.º 19
0
		// 移除摄像头
		public void Remove(Camera camera)
		{
			Monitor.Enter(this);

			int n = InnerList.Count;
			for (int i = 0; i < n; i++)
			{
				if (InnerList[i] == camera)
				{
					if (camera.Running)
						camera.Stop();
					camera.CloseVideoSource();
					InnerList.RemoveAt(i);
					break;
				}
			}

			Monitor.Exit(this);
		}
Exemplo n.º 20
0
 // 拍照功能函数
 private void takephoto()
 {
     cameraToEdit = multiplexer.LastClicked.Camera;
     if (cameraToEdit == null)
     {
         MessageBox.Show("你当前没有选中摄像头!");
         return;
     }
     removeform();
     if (cameraToEdit.Provider.Name == "EasyN IP Camera")
     {
         cameraCGI.snapshot(cameraToEdit);
     }
     else
     {
         cameraToEdit.TakePhoto();
     }
 }
Exemplo n.º 21
0
        // 把camera从集合中移除
		public void Remove(Camera camera)
		{
			InnerList.Remove(camera);
		}
Exemplo n.º 22
0
 // 定时抓拍功能函数
 private void takepictures()
 {
     cameraToEdit = multiplexer.LastClicked.Camera;
     if (cameraToEdit == null && tsmi定时抓拍.Text == "定时抓拍")
     {
         MessageBox.Show("你当前没有选中摄像头!");
         return;
     }
     removeform();
     if (tsmi定时抓拍.Text == "定时抓拍")
     {
         zhuapai = true;
         tsb监测.Text = " 停止抓拍 ";
         tsmi定时抓拍.Text = "停止抓拍";
         tsb监测.Image = Properties.Resources.monitor7;
     }
     else
     {
         zhuapai = false;
         tsb监测.Text = " 定时抓拍 ";
         tsmi定时抓拍.Text = "定时抓拍";
         tsb监测.Image = Properties.Resources.monitor5;
         CountPhoto = 0;
     }
 }
Exemplo n.º 23
0
		// 新增摄像头
		public void AddCamera(Camera camera)
		{
			camera.ID = nextCameraID++;
			cameras.Add(camera);
			SaveCameras();
		}
Exemplo n.º 24
0
        // 录制功能函数
        private void records()
        {
            removeform();

            cameraToEdit = multiplexer.LastClicked.Camera;
                     // 把正在录制的摄像头存入变量,关闭录制时调用
            if (cameraToEdit == null && tsmi录制.Text == "录制")  //在录制当中也有可能,cameraToEdit == null
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }
            if (tsmi录制.Text == "录制")
            {
                cameraRecording = cameraToEdit;  
                RecordOpen();       //开始录制
                tsb录制.Text = " 停止录制 ";
                tsb录制.Image = ((System.Drawing.Image)(resource.GetObject("stop.Image")));
                tsmi录制.Text = "停止录制";
            }
            else
            {
                cameraToEdit = cameraRecording;
                RecordClose();      //停止录制
                tsb录制.Text = "   录制   ";
                tsb录制.Image = ((System.Drawing.Image)(resource.GetObject("tsb录制.Image")));
                tsmi录制.Text = "录制";
            }
        }
Exemplo n.º 25
0
		// 删除摄像头
		public bool DeleteCamera(Camera camera)
		{
			cameras.Remove(camera);
			SaveCameras();
			return true;
		}
Exemplo n.º 26
0
        // 异常监测功能函数    
        private void detection()
        {
            cameraToEdit = multiplexer.LastClicked.Camera;
            if (cameraToEdit == null && jiance == false)
            {
                MessageBox.Show("你当前没有选中摄像头!");
                return;
            }
            removeform();

            if (jiance == false) 
            {  
                // 开始监测
                cameraToEdit = multiplexer.LastClicked.Camera;
                cameraDetecting = cameraToEdit;                 // 存放监测的摄像头
                tsb异常监测.Image = Properties.Resources.camera7;
                detector = new MotionDetector(new TwoFramesDifferenceDetector());
                jiance = true;
                tsb异常监测.Text = " 停止监测 ";
                tsmi异常监测.Text = "停止监测";
            }
            else
            {  
                // 关闭监测
                detector = null;
                tsb异常监测.Image = Properties.Resources.camera5;
                jiance = false;
                tsb异常监测.Text = " 异常监测 ";
                tsmi异常监测.Text = "异常监测";

                if (luzhi1 == true)
                {
                    CountVedio = 0;
                    cameraToEdit = cameraDetecting;
                    RecordClose();
                    luzhi1 = false;
                    timer2.Enabled = true;
                    MainForm.Instance().ShowForm();
                }
                //  timer2.Enabled = true;
                // MainForm.Instance().ShowForm();
            }
        }
Exemplo n.º 27
0
 // 检查摄像头是否已经存在
 private bool CheckCamera(Camera camera)
 {
     return config.CheckCamera(camera);
 }
Exemplo n.º 28
0
        // 定时器1——流量统计 
        private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            // 定时抓拍功能
            if (zhuapai == true)
            {
                CountPhoto++;
                if (CountPhoto == 6)
                {
                    takephoto();
                    CountPhoto = 0;
                }
            }

            // 异常监测功能
            if (jiance == true)
            {
                if (luzhi1 == false && motionLevel < 1 && motionLevel > motionAlarmLevel)
                {
                    luzhi1 = true;
                    motionLevel = 0;
                    RecordOpen();
                }
                if (luzhi1 == true)
                {
                    CountVedio++;
                    if (CountVedio == 20)
                    {
                        RecordClose();
                        CountVedio = 0;
                        cameraToEdit = cameraDetecting;
                        luzhi1 = false;
                        timer2.Enabled = true;
                        MainForm.Instance().ShowForm();
                    }
                }
            }
        
            if (runningPool.Count != 0)
            {
                float fps = 0, bps = 0;
                statCount[statIndex] = 0;
                statReceived[statIndex] = 0;
                foreach (Camera camera in runningPool)
                {
                    statCount[statIndex] += camera.FramesReceived;
                    statReceived[statIndex] += camera.BytesReceived;
                }

                if (++statIndex >= statLength)
                    statIndex = 0;
                if (statReady < statLength)
                    statReady++;

                // 计算平均值
                for (int i = 0; i < statReady; i++)
                {
                    fps += statCount[i];
                    bps += statReceived[i];
                }
                fps /= statReady;
                bps /= (statReady * 1024);

                statReceived[statIndex] = 0;
                statCount[statIndex] = 0;

                fpsPanel.Text = fps.ToString("F2") + " fps";
                bpsPanel.Text = bps.ToString("F2") + " Kb/s";
            }
        }