//Constructor----------------------------------------------------------------- /// <summary> /// Constructor which set all connections, detections settings and camera settings /// </summary> /// <param name="cam">Camera Settings</param> /// <param name="con">Connections Settings</param> /// <param name="det">Detection Settings</param> public VideoAnalyzer(CameraValues cam, Connections con, DetectionSetting det) { //Setting Camera/Connection camera = cam.Clone(); connections = con.Clone(); detectionSettings = det.Clone(); //Manager Instantiation if (camera.MjpegStreamer) { Video = new VideoStreamManager(); } else { Video = new SnapshotStreamManager(); } Detector = new FaceDetectionManager(); Sentiment = new FaceSentimentManager(); //Set Connections Sentiment.SetConnections(connections, camera); Detector.SetDetectionsSetting(detectionSettings); Video.SetConnections(camera); MaxRestart = connections.TimesOfRestart; //Set Event Video.FrameHandler += GetFrame; Video.ErrorStreamHandler += ErrorHandler; //Set Timer streamTimer = new Timer(); connectionTimer = new Timer(); restartTimer = new Timer(); detectionTimer = new Timer(); //streamTimer.Interval = new TimeSpan(0, 0, 0, camera.SecondTimeOut); //connectionTimer.Interval = new TimeSpan(0, 0, connections.SecondTimeout * 2); //restartTimer.Interval = new TimeSpan(0, 0, connections.SecondTimeout); //detectionTimer.Interval = new TimeSpan(0, 0, detectionSettings.SecondForDetection); streamTimer.Interval = camera.SecondTimeOut * 1000; connectionTimer.Interval = connections.SecondTimeout * 2 * 1000; restartTimer.Interval = connections.SecondTimeout * 1000; detectionTimer.Interval = detectionSettings.SecondForDetection * 1000; streamTimer.Elapsed += StreamNotWorking; restartTimer.Elapsed += TryRestart; connectionTimer.Elapsed += ConnectionNotWorking; detectionTimer.Elapsed += DetectFace; string root = System.Web.HttpContext.Current.Server.MapPath("~/Settings"); LogsFilePath = string.Format("{0}\\{1}", root, "Logs\\LogsError.txt"); }
public void UpdateDetections(DetectionSetting detection, string filePath) { try { System.IO.File.WriteAllLines(filePath, new string[] { detection.ToString() }); } catch (Exception ex) { return; } }