Exemple #1
0
        public static IEnumerable <ImageExample> ReadCsv(string filePath)
        {
            var csvEntries    = ReadCsvEntries(filePath);
            var imageExamples = new List <ImageExample>();

            foreach (var csvEntry in csvEntries)
            {
                var imageExample = imageExamples.FirstOrDefault(example => example.Filename == csvEntry.Filename);
                if (imageExample == default(ImageExample))
                {
                    imageExample = new ImageExample
                    {
                        Filename    = csvEntry.Filename,
                        ImageFormat = csvEntry.ImageFormat,
                        Height      = csvEntry.Height,
                        Width       = csvEntry.Width
                    };

                    imageExamples.Add(imageExample);
                }
                imageExample.Bounds.Add(new Tuple <ObjectClass, Point, Point>(
                                            HelperStructures.ObjectClassMapping.FirstOrDefault(m => m.Value == csvEntry.Class).Key,
                                            new Point(csvEntry.XMin, csvEntry.YMin),
                                            new Point(csvEntry.XMax, csvEntry.YMax)));
            }

            return(imageExamples);
        }
        private void LoadNextImage()
        {
            if (_unprocessedImagePathEnumerator.MoveNext())
            {
                Debug.Assert(_unprocessedImagePathEnumerator.Current != null, "_unprocessedImagePathEnumerator.Current != null");
                var currentImagePath = _unprocessedImagePathEnumerator.Current.ToString();
                currentImagePictureBox.BackgroundImage = Image.FromFile(currentImagePath);
                currentImagePictureBox.Image           = new Bitmap(currentImagePictureBox.BackgroundImage.Width, currentImagePictureBox.BackgroundImage.Height);

                _currentImageExample = new ImageExample
                {
                    Filename    = currentImagePath,
                    ImageFormat = HelperStructures.ImageFormatMapping[ImageFormat.PNG],
                    Width       = currentImagePictureBox.BackgroundImage.Width,
                    Height      = currentImagePictureBox.BackgroundImage.Height
                };
                ResetCurrentBound();
            }
            else
            {
                MessageBox.Show("All images were successfully processed.\r\n" +
                                "Image data saved in: " + ProcessedFilesPath + "\r\n" +
                                "CSV description file saved in: " + CsvPath + "\r\n",
                                "All images processed!");
                Close();
            }
        }