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(); }
private IList <OpenALPRmilestoneCameraName> GetCameraFromMapping(string cameraId) { DateTime temp = CameraMapper.GetLastWriteTime(); if (temp != lastMappingUpdateTime) { CameraMapper.LoadCameraList(cameraList); lastMappingUpdateTime = temp; Program.Log.Info("Reload camera mapping list"); } List <OpenALPRmilestoneCameraName> cameras = cameraList.Where(c => c.OpenALPRId == cameraId).ToList(); if (cameras.Count == 0) { Program.Log.Warn($"{cameraId} not found in the local camera list"); } return(cameras); }
// 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); }