Beispiel #1
0
        public Mat Detect(Mat img)
        {
            //var img = new Mat(path);
            var items = _wrapper.Detect(img.ToBytes());

            for (int i = 0; i < items.Count(); i++)
            {
                // Объекты будут отображаться только при уверенность больше 80%
                if (items.ElementAt(i).Confidence > 0.8)
                {
                    var xmin   = Int32.Parse(items.ElementAt(i).X.ToString());
                    var ymin   = Int32.Parse(items.ElementAt(i).Y.ToString());
                    var width  = Int32.Parse(items.ElementAt(i).Width.ToString());
                    var height = Int32.Parse(items.ElementAt(i).Height.ToString());

                    Rect rect = new Rect(xmin, ymin, width, height);
                    img.Rectangle(rect, Scalar.Blue, 3, LineTypes.AntiAlias, 0);

                    //_logControler.AddMessage($@"Тип объекта: {items.ElementAt(i).Type.ToString()}");
                    //_logControler.AddMessage($@"X: {xmin}, Y: {ymin}, Width: {width}, Height: {height}");
                    //_logControler.AddMessage($@"Уверенность: {items.ElementAt(i).Confidence.ToString("#0.##%")}");

                    // Выводим в лог тип объекта, его положение и уверенность обнаружения.
                    _logControler.AddMessage($@"Тип объекта: {items.ElementAt(i).Type.ToString()}  X: {xmin}, Y: {ymin}, Width: {width}, Height: {height}  Уверенность: {items.ElementAt(i).Confidence.ToString("#0.##%")}");
                }
            }
            return(img);
        }
Beispiel #2
0
        /// <summary> Загрузить настройки проекта.</summary>
        public async Task LoadXMLAsync()
        {
            await Task.Run(() =>
            {
                XDocument xdoc = XDocument.Load(_pathXML);

                IsDetector     = bool.Parse(xdoc.Root.Element("IsDetector").Value);
                IsUnderCatalog = bool.Parse(xdoc.Root.Element("IsUnderCatalog").Value);

                _logControler.AddMessage($"{IsDetector} - {IsUnderCatalog}");
            });
        }
Beispiel #3
0
        /// <summary> Открыть директорию с картинками. </summary>
        /// <param name="path"> Путь к директории. </param>
        public void OpenFolderWithImages(string path)
        {
            IEnumerable <string> _filesDirectory = null;

            if (_projectSettings.IsUnderCatalog)
            {
                _filesDirectory = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories)
                                  .Where(s => s.EndsWith(".png") || s.EndsWith(".jpg") || s.EndsWith(".bmp") || s.EndsWith(".jpeg"));
            }
            else
            {
                _filesDirectory = Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly)
                                  .Where(s => s.EndsWith(".png") || s.EndsWith(".jpg") || s.EndsWith(".bmp") || s.EndsWith(".jpeg"));
            }


            _listImage = _filesDirectory.ToList();

            _curentImage = 0;
            _countImage  = _filesDirectory.Count();

            // Проверяем наличие файлов с нужным расширением.
            if (_countImage != 0)
            {
                AddImageOnControl(_listImage[_curentImage]);
                _logControler.AddMessage($"{_curentImage} {_countImage}");
            }
            else
            {
                _logControler.AddMessage("Изображений не обнаружено!");
            }
        }
Beispiel #4
0
        /// <summary> Вызывается по нажаитю на кнопку сохранить проект. </summary>
        private async void OnSaveClickAsync(object sender, EventArgs e)
        {
            await _projectSettings.SaveXMLAsync();

            _logControler.AddMessage("Настройки проекта сохранены в XML файле.");
        }