コード例 #1
0
        public void LSTGeneratorShould()
        {
            var annotationsList = new ImageAnnotationsList();

            annotationsList.Annotations = new List <ImageAnnotaion>();


            string[] sourceFiles = Directory.GetFiles(folderWithImagesPath, "*", SearchOption.AllDirectories);
            foreach (string file in sourceFiles)
            {
                using (Stream stream = File.OpenRead(file))
                {
                    using (Image sourceImage = Image.FromStream(stream, false, false))
                    {
                        ImageAnnotaion imageAnnotation = new ImageAnnotaion(file);
                        imageAnnotation.ImageLabels = new List <ImageAnnotationLabel>();
                        ImageAnnotationLabel item = new ImageAnnotationLabel();

                        imageAnnotation.ImageLabels.Add(item);
                        annotationsList.Annotations.Add(imageAnnotation);
                    }
                }
            }

            Assert.IsTrue(annotationsList.Annotations.ToList().Any());
        }
コード例 #2
0
        public void ImageAnnotationHasAllMandatoryPropertiesDefaults()
        {
            ImageAnnotaion testIA;

            using (Stream stream = File.OpenRead(dog1ImagePath))
            {
                using (Image sourceImage = Image.FromStream(stream, false, false))
                {
                    //Console.WriteLine(sourceImage.Width);
                    //Console.WriteLine(sourceImage.Height);
                    testIA = new ImageAnnotaion(dog1ImagePath);
                }
            }
            Assert.IsFalse(String.IsNullOrEmpty(testIA.Path));
            Assert.AreEqual(2, testIA.HeaderSize);
            Assert.AreEqual(5, testIA.LabelWidth);
        }
コード例 #3
0
        public void ImageAnnotationListSerialization()
        {
            string result = "44\t2\t5\t11.0000\t0.2480\t0.0027\t0.9220\t0.8080\t2010_000152.jpg";

            var imageLabel = new ImageAnnotationLabel();

            imageLabel.ClassIndex = 11;
            imageLabel.XMin       = 0.248F;
            imageLabel.YMin       = 0.0027F;
            imageLabel.XMax       = 0.9220F;
            imageLabel.YMax       = 0.8080F;

            var imageAnnotation = new ImageAnnotaion("2010_000152.jpg");

            imageAnnotation.ImageIndex = 44;

            imageAnnotation.ImageLabels = new System.Collections.Generic.List <ImageAnnotationLabel>();
            imageAnnotation.ImageLabels.Add(imageLabel);

            string ImageAnnotationSerialized = imageAnnotation.ToString();

            Assert.AreEqual(result, ImageAnnotationSerialized);
        }
コード例 #4
0
        public void ImageAnnotationHeaderSizeCanbeChanged()
        {
            var testIA = new ImageAnnotaion(dog1ImagePath, headerSize: 3);

            Assert.AreEqual(3, testIA.HeaderSize);
        }
コード例 #5
0
        public void ImageAnnotationLabelWidhtCanbeChanged()
        {
            var testIA = new ImageAnnotaion(dog1ImagePath, headerSize: 2, labelWidth: 4);

            Assert.AreEqual(4, testIA.LabelWidth);
        }