Exemplo n.º 1
0
        public void DetectBlobsNone()
        {
            // no blob
            string[] inGrid =
            {
                "XXXXXX",
                "XXXXXX",
                "XXXXXX",
                "XXXXXX",
            };

            string[] outGrid =
            {
                "@@@@@@",
                "@@@@@@",
                "@@@@@@",
                "@@@@@@",
            };

            bool[][] map = GridTest.InitBoolGrid(inGrid);
            int[][] blob = GridTest.InitIntGrid(outGrid);

            List<BlobMap.Blob> compareBlobs = new List<BlobMap.Blob>();

            bool LocTest(Loc loc) => map[loc.X][loc.Y];
            BlobMap result = Detection.DetectBlobs(new Rect(0, 0, map.Length, map[0].Length), LocTest);
            Assert.That(result.Map, Is.EqualTo(blob));
            Assert.That(result.Blobs, Is.EqualTo(compareBlobs));
        }
Exemplo n.º 2
0
        public void DetectBlobsSingle()
        {
            // single blob
            string[] inGrid =
            {
                "XXXXXX",
                "X..XXX",
                "X....X",
                "X.XXXX",
                "XXXXXX",
            };

            string[] outGrid =
            {
                "@@@@@@",
                "@AA@@@",
                "@AAAA@",
                "@A@@@@",
                "@@@@@@",
            };

            bool[][] map = GridTest.InitBoolGrid(inGrid);
            int[][] blob = GridTest.InitIntGrid(outGrid);

            var compareBlobs = new List<BlobMap.Blob> { new BlobMap.Blob(new Rect(1, 1, 4, 3), 7) };

            bool LocTest(Loc loc) => map[loc.X][loc.Y];
            BlobMap result = Detection.DetectBlobs(new Rect(0, 0, map.Length, map[0].Length), LocTest);
            Assert.That(result.Map, Is.EqualTo(blob));
            Assert.That(result.Blobs, Is.EqualTo(compareBlobs));
        }
Exemplo n.º 3
0
        public void DetectBlobsCorners()
        {
            // diagonal attached blobs
            string[] inGrid =
            {
                "..XX..",
                "..XX..",
                "XXXXXX",
                "XXXXXX",
            };

            string[] outGrid =
            {
                "AA@@BB",
                "AA@@BB",
                "@@@@@@",
                "@@@@@@",
            };

            bool[][] map = GridTest.InitBoolGrid(inGrid);
            int[][] blob = GridTest.InitIntGrid(outGrid);

            var compareBlobs = new List<BlobMap.Blob>
            {
                new BlobMap.Blob(new Rect(0, 0, 2, 2), 4),
                new BlobMap.Blob(new Rect(4, 0, 2, 2), 4),
            };

            bool LocTest(Loc loc) => map[loc.X][loc.Y];
            BlobMap result = Detection.DetectBlobs(new Rect(0, 0, map.Length, map[0].Length), LocTest);
            Assert.That(result.Map, Is.EqualTo(blob));
            Assert.That(result.Blobs, Is.EqualTo(compareBlobs));
        }