예제 #1
0
            public double process(Image image, Rectangle rect, TableIdentifier parent)
            {
                // colors
                Image cropped  = crop(image, rect);
                Image reduced  = reducer.reduceColors(cropped);
                Image replaced = replacer.replace(reduced);

                // image
                parent.renderImage(inker.replace(replaced), rect);

                // partition
                List <List <Image> > lines = HorizontalPartitioner.partition(replaced);

                if (lines.Count == 0)
                {
                    return(Table.NO_POT);
                }

                // chars
                String textLine = "";

                foreach (Image chars in lines[0])
                {
                    List <Image> combos = CharDecomposer.decompose(chars);
                    foreach (Image chr in combos)
                    {
                        Image character = ImageCropper.crop(chr);
                        textLine += identifyChars(character);
                    }
                }

                // check for digit
                if (!TextTools.ContainsDigit(textLine))
                {
                    return(Table.NO_POT);
                }

                // format
                textLine = textLine.Replace("$", "").Replace("?", "").Trim();

                // money
                return(TextTools.ParseDouble(textLine));
            }
예제 #2
0
            public double process(Image image, Rectangle rect, TableIdentifier parent)
            {
                // colors
                Image reduced  = reducer.reduceColors(image);
                Image inverted = inverter.invert(reduced);
                Image replaced = replacer.replace(inverted);

                // image
                parent.renderImage(inker.replace(replaced), rect);

                // partition
                List <List <Image> > lines = HorizontalPartitioner.partition(replaced);

                if (lines.Count == 0)
                {
                    return(Player.NO_BET);
                }

                // chars
                String textLine = "";

                foreach (Image chars in lines[0])
                {
                    List <Image> combos = CharDecomposer.decompose(chars);
                    foreach (Image chr in combos)
                    {
                        Image character = ImageCropper.crop(chr);
                        textLine += identifyChars(character);
                    }
                }

                // check for digit
                if (!TextTools.ContainsDigit(textLine))
                {
                    return(Player.NO_BET);
                }

                // sanity check
                if (!textLine.Contains("$"))
                {
                    throw new ArgumentException("bet text has no dollar sign");
                }

                // replace all non-numeric chars
                textLine = textLine.Trim();
                string numericTextLine = textLine;

                foreach (char chr in textLine)
                {
                    if (!TextTools.IsNumeric(chr) && !TextTools.IsPoint(chr))
                    {
                        numericTextLine = numericTextLine.Replace(chr.ToString(), "");
                    }
                }


                // sanity check (sometimes some pixels are identifier as '.')
                if (numericTextLine.StartsWith("."))
                {
                    numericTextLine = numericTextLine.Substring(1);
                }

                // money
                return(TextTools.ParseDouble(numericTextLine));
            }