Пример #1
0
        public Worker()
        {
            cameraList = new List <OpenALPRmilestoneCameraName>();
            CameraMapper.LoadCameraList(cameraList);
            lastMappingUpdateTime = CameraMapper.GetLastWriteTime();

            openALPRList = new List <KeyValuePair <string, string> >();
            OpenALPRLNameHelper.LoadCameraNameList(openALPRList);

            dicBlack = new Dictionary <string, string>();
            AlertListHelper.LoadAlertList(dicBlack);
            lastAlertUpdateTime = AlertListHelper.GetLastWriteTime();
        }
Пример #2
0
        private void CameraMapping_Load(object sender, EventArgs e)
        {
            var namesList = new List <KeyValuePair <string, string> >();

            OpenALPRLNameHelper.FillCameraNameList(namesList);

            if (namesList.Count != 0)
            {
                namesList = namesList.OrderBy(o => o.Key).ToList();
                namesList.Insert(0, new KeyValuePair <string, string>("-1", "No ALPR mapping"));
            }

            var cameraItems = new List <Item>();

            OpenALPRBackgroundPlugin.FindAllCameras(Configuration.Instance.GetItemsByKind(Kind.Camera), cameraItems);
            for (int i = 0; i < cameraItems.Count; i++)
            {
                var cameraPairControl = new CameraPairControl();

                cameraPairControl.cboName.DataSource    = new BindingSource(namesList, null);
                cameraPairControl.cboName.DisplayMember = "Value";
                cameraPairControl.cboName.ValueMember   = "Key";

                cameraPairControl.TxtMilestoneCameraName.Text = cameraItems[i].Name;
                var mapping = CameraList.FirstOrDefault(m => m.MilestoneName == cameraItems[i].Name);
                if (mapping != null)
                {
                    var index = namesList.FindIndex(a => a.Key == mapping.OpenALPRId);
                    if (index > -1)
                    {
                        cameraPairControl.cboName.SelectedIndex = index;
                    }
                }

                flowLayoutPanel1.Controls.Add(cameraPairControl);
            }
        }
Пример #3
0
        // Auto mapping happened when there is an ip address in videoStream.Url : rtsp://mhill:[email protected]/onvif-media / media.amp ? profile = balanced_h264 & sessiontimeout = 60 & streamtype = unicast
        private bool ProcessAlprHeartbeat(Heartbeats heartbeats)
        {
            if (heartbeats != null)
            {
                for (int i = 0; i < heartbeats.Video_streams.Count; i++)
                {
                    VideoStream videoStream = heartbeats.Video_streams[i];
                    if (videoStream != null)
                    {
                        KeyValuePair <string, string> kv = new KeyValuePair <string, string>(videoStream.Camera_id.ToString(), videoStream.Camera_name);
                        if (!openALPRList.Contains(kv))
                        {
                            openALPRList.Add(kv);
                            OpenALPRLNameHelper.SaveCameraNameList(openALPRList);
                        }

                        long cameraId = videoStream.Camera_id;
                        if (!string.IsNullOrEmpty(videoStream.Url) && AutoMapping) ////rtsp://mhill:[email protected]/onvif-media / media.amp ? profile = balanced_h264 & sessiontimeout = 60 & streamtype = unicast
                        {
                            Match match = Regex.Match(videoStream.Url, @"\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b");
                            if (match.Success)
                            {
                                // 1st case (No Camera_id found): AXIS M1054 Network Camera (192.168.0.36) - Camera 1|TestCamera|
                                bool exists = cameraList.Any(m => m.OpenALPRId == videoStream.Camera_id.ToString());

                                if (!exists)
                                {
                                    exists = cameraList.Any(m => m.OpenALPRname == videoStream.Camera_name);
                                    if (exists)
                                    {
                                        IEnumerable <OpenALPRmilestoneCameraName> cameras = cameraList.Where(m => m.OpenALPRname == videoStream.Camera_name);
                                        foreach (OpenALPRmilestoneCameraName camera in cameras)
                                        {
                                            camera.OpenALPRId = videoStream.Camera_id.ToString();
                                        }

                                        CameraMapper.SaveCameraList(cameraList);
                                    }
                                }

                                // 2nd case (No Camera_id No Camera_Name found): AXIS M1054 Network Camera (192.168.0.36) - Camera 1
                                if (!exists)
                                {
                                    Item milestoneCamera = MilestoneServer.GetCameraItem(match.Captures[0].Value);
                                    if (milestoneCamera != null)
                                    {
                                        exists = cameraList.Any(m => m.MilestoneName == milestoneCamera.Name);
                                        if (exists)
                                        {
                                            IEnumerable <OpenALPRmilestoneCameraName> cameras = cameraList.Where(m => m.MilestoneName == milestoneCamera.Name);
                                            foreach (OpenALPRmilestoneCameraName camera in cameras)
                                            {
                                                camera.OpenALPRId   = videoStream.Camera_id.ToString();
                                                camera.OpenALPRname = videoStream.Camera_name;
                                            }
                                            CameraMapper.SaveCameraList(cameraList);
                                        }
                                        else
                                        {
                                            OpenALPRmilestoneCameraName camera = new OpenALPRmilestoneCameraName
                                            {
                                                MilestoneName = milestoneCamera.Name,
                                                OpenALPRId    = videoStream.Camera_id.ToString(),
                                                OpenALPRname  = videoStream.Camera_name
                                            };
                                            cameraList.Add(camera);
                                            CameraMapper.SaveCameraList(cameraList);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }