Ejemplo n.º 1
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);
            }
        }