private void yoloDispose() { if (usingYolo) { _yoloWrapper.Dispose(); } }
private void Check(GpuConfig gpuConfig) { var yoloWrapper = new YoloWrapper("yolov2-tiny-voc.cfg", "yolov2-tiny-voc.weights", "voc.names", gpuConfig); var files = Directory.GetFiles(@".\Images"); var retrys = 10; var sw = new Stopwatch(); foreach (var file in files) { var elapsed = 0.0; var fileInfo = new FileInfo(file); var imageData = File.ReadAllBytes(file); for (var i = 0; i < retrys; i++) { sw.Restart(); yoloWrapper.Detect(imageData); sw.Stop(); elapsed += sw.Elapsed.TotalMilliseconds; } var average = elapsed / retrys; Console.WriteLine($"{fileInfo.Name} {average}ms"); } yoloWrapper.Dispose(); }
/// <summary> /// Compare yolo speed with optimal images in the correct size /// Resize before and resize in yolo /// </summary> public void Start() { var yoloWrapper = new YoloWrapper("yolov2-tiny-voc.cfg", "yolov2-tiny-voc.weights", "voc.names"); var files = Directory.GetFiles(@".\Images"); var imageResizer = new ImageResizer(); var retries = 10; Console.WriteLine("|{0,20}|{1,29}|{2,43}|", "", "Resize with yolo", "Resize before yolo"); Console.WriteLine("|{0,20}|{1,15}|{2,13}|{3,15}|{4,13}|{5,13}|{6,10}|{7,10}|", "Image", "detected items", "elapsed (ms)", " detected items", "resize (ms)", "yolo (ms)", "diff (ms)", "faster"); foreach (var file in files) { for (var i = 0; i < retries; i++) { var fileInfo = new FileInfo(file); var imageData = File.ReadAllBytes(file); var result1 = ProcessResizeAfter(yoloWrapper, imageData); var result2 = ProcessResizeBefore(yoloWrapper, imageResizer, imageData); var diff = result1.Item3 - result2.Item4; Console.WriteLine("|{0,20}|{1,15}|{2,13}|{3,15}|{4,13}|{5,13}|{6,10}|{7,10}|", fileInfo.Name, result1.Item1.Count, result1.Item2, result2.Item1.Count, result2.Item2, result2.Item3, diff.ToString("0.00"), diff > 0); } } yoloWrapper.Dispose(); }
private void SetupYolo(List <YoloEntry> configs, YoloEntry.YoloSelection selection) { if (yoloWrapper != null) { yoloWrapper.Dispose(); yoloWrapper = null; } var config = configs.Find(x => x.Selection == selection).Conf; if (config.IsValid) { configurationDetector = new ConfigurationDetector(config); config = configurationDetector.Detect(); yoloWrapper = new YoloWrapper(config); } else { throw new InvalidDataException("Configuration files missing!"); } }
private void Initialize(YoloConfiguration config) { try { if (_yoloWrapper != null) { _yoloWrapper.Dispose(); } var gpuConfig = new GpuConfig(); var useOnlyCpu = cpuToolStripMenuItem.Checked; if (useOnlyCpu) { gpuConfig = null; } toolStripStatusLabelYoloInfo.Text = $"Initialize..."; var sw = new Stopwatch(); sw.Start(); _yoloWrapper = new YoloWrapper(config.ConfigFile, config.WeightsFile, config.NamesFile, gpuConfig); sw.Stop(); var action = new MethodInvoker(delegate { var deviceName = _yoloWrapper.GetGraphicDeviceName(gpuConfig); toolStripStatusLabelYoloInfo.Text = $"Initialize Yolo in {sw.Elapsed.TotalMilliseconds:0} ms - Detection System:{_yoloWrapper.DetectionSystem} {deviceName} Weights:{config.WeightsFile}"; }); statusStrip1.Invoke(action); buttonProcessImage.Invoke(new MethodInvoker(delegate { buttonProcessImage.Enabled = true; })); buttonStartTracking.Invoke(new MethodInvoker(delegate { buttonStartTracking.Enabled = true; })); } catch (Exception exception) { MessageBox.Show($"{nameof(Initialize)} - {exception}", "Error Initialize", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Dispose() { wrap?.Dispose(); }
private void Main_FormClosing(object sender, FormClosingEventArgs e) { _yoloWrapper?.Dispose(); }
public void KillYolo() => yolo.Dispose();
protected virtual void Dispose(bool disposing) { _yoloWrapper?.Dispose(); }
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { videoPlayer.Stop(); _yoloWrapper?.Dispose(); }
public void Dispose() { yoloWrapper.Dispose(); }