private void dispatcherTimer_Tick(object sender, EventArgs e) { var frame = new Mat(); Camera.NextFrame(frame); CameraFrame = frame.ToBitmapSource(); if (SvmClassifier == null) { return; } if (!IsStarted) { return; } foreach (var slot in ParkingSlots) { var contour = new Contour(slot.Pts .Select(point => new Contour.Point() { X = point.X, Y = point.Y, })); var features = frame.CalculateFeatures(contour, false); Debug.WriteLine(features); slot.IsOccupied = SvmClassifier.Predict(features); } }
public static List <ImageFeatures> GetObservations(string directoryPath, bool reloadChache = false, Action <int, int> reportProgres = null) { if (!reloadChache && LoadCacheObservations(directoryPath, out var observations)) { return(observations); } observations = new List <ImageFeatures>(); var paths = GetPhotos(directoryPath); var progress = 0; reportProgres?.Invoke(progress, paths.Count); foreach (var path in paths) { using (var image = new Mat(path)) { foreach (var slot in LoadSlots(path)) { var calculateFeatures = image.CalculateFeatures(slot.Contour, slot.IsOccupied); GC.Collect(); GC.WaitForPendingFinalizers(); observations.Add(calculateFeatures); } reportProgres?.Invoke(++progress, paths.Count); } GC.Collect(); GC.WaitForPendingFinalizers(); } SaveCacheObservations(directoryPath, observations); return(observations); }