public static async Task <Session> Start(CameraObject cameraObject, string name, string fileOutput = null) { if (sourcesOpen.Any(i => i.Equals(cameraObject.Name))) { return(null); } var session = new Session() { IsSourceFromCamera = true, Source = cameraObject.ToString(), FileOutput = fileOutput, Name = name }; session.Datastore = await Datastore.Initialize(session); session.FrameSource = await FrameSource.Initialize(session); session.GridProjection = await GridProjection.Initialize(session); session.Logger = await Logger.Initialize(session); session.HumanDetector = await HumanDetector.Initialize(session); sourcesOpen.Add(cameraObject.ToString()); return(session); }
public static async Task <Datastore> Initialize(Session session) { return(await Task.Run(delegate { var datastore = new Datastore { filePath = Path.Combine("Session", session.Name, "Datastore") }; try { if (!Directory.Exists(Path.GetDirectoryName(datastore.filePath))) { Directory.CreateDirectory(Path.GetDirectoryName(datastore.filePath)); } if (!File.Exists(datastore.filePath)) { File.WriteAllText(datastore.filePath, ""); } datastore.fileContent = File.ReadAllText(datastore.filePath); } catch { } return datastore; })); }