예제 #1
0
        public string RecognizeNumber(Bitmap img)
        {
            var count = finder.CountColor(img, Color.FromArgb(0, 0, 0), 10);

            switch (count)
            {
            case OneOrSeven:
                return(Differenciate(new List <string> {
                    "1", "7"
                }, img));

            case TwoOrFiveOrNine:
                return(Differenciate(new List <string> {
                    "9", "5", "2"
                }, img));

            case ThreeOrFour:
                return(Differenciate(new List <string> {
                    "3", "4"
                }, img));

            case SixOrZero:
                return(Differenciate(new List <string> {
                    "0", "6"
                }, img));;

            case Heigh:
                return("8");
            }
            return("0");
        }
예제 #2
0
        public void ReturnsTheNumberOfTimesAColorWasFound()
        {
            Img = new Bitmap(2, 2);
            Img.SetPixel(1, 1, Color.FromArgb(255, 0, 0));
            Img.SetPixel(0, 1, Color.FromArgb(255, 0, 0));
            Img.SetPixel(1, 0, Color.FromArgb(0, 255, 0));

            var actual = ColorFinder.CountColor(Img, Color.FromArgb(255, 0, 0));


            Assert.AreEqual(2, actual);
        }