Esempio n. 1
0
 private void yoloDispose()
 {
     if (usingYolo)
     {
         _yoloWrapper.Dispose();
     }
 }
Esempio n. 2
0
        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();
        }
Esempio n. 4
0
        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!");
            }
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
 public void Dispose()
 {
     wrap?.Dispose();
 }
Esempio n. 7
0
 private void Main_FormClosing(object sender, FormClosingEventArgs e)
 {
     _yoloWrapper?.Dispose();
 }
Esempio n. 8
0
 public void KillYolo() => yolo.Dispose();
Esempio n. 9
0
 protected virtual void Dispose(bool disposing)
 {
     _yoloWrapper?.Dispose();
 }
Esempio n. 10
0
 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     videoPlayer.Stop();
     _yoloWrapper?.Dispose();
 }
Esempio n. 11
0
 public void Dispose()
 {
     yoloWrapper.Dispose();
 }