private List <String> identifyLines(Image replaced, Rectangle rect, TableIdentifier parent) { // image parent.renderImage(inker.replace(replaced), rect); // partition List <List <Image> > lines = HorizontalPartitioner.partition(replaced); // chars List <String> textLines = new List <String>(); foreach (List <Image> line in lines) { String textLine = ""; foreach (Image chars in line) { List <Image> combos = CharDecomposer.decompose(chars); foreach (Image chr in combos) { Image character = ImageCropper.crop(chr); textLine += identifyChars(character); } } textLines.Add(textLine); } return(textLines); }
public bool process(Image image, Rectangle rect, TableIdentifier parent) { // crop Image cropped = crop(image, rect); // real color unknown if (realButtonColor == null) { // colors Image reduced = reducer.reduceColors(cropped); parent.renderImage(reduced, rect); // check bool visible = ControlsIdentifier.areReducedControlsVisible(reduced); if (visible) { realButtonColor = ImageTools.getSignificantColorRange(cropped); } return(visible); } // real color known else { // check return(ControlsIdentifier.areControlsVisibleWithNativeColor(cropped, realButtonColor)); } }
public bool process(Image image, Rectangle rect, TableIdentifier parent) { // colors Image reduced = reducer.reduceColors(image); // render parent.renderImage(reduced, rect); // positions return(SmallCardsIdentifier.areReducedSmallCards(reduced)); }
public List <Card> process(Image image, Rectangle rect, TableIdentifier parent) { // colors Image reduced = reducer.reduceColors(image); parent.renderImage(reduced, rect); // hand List <Card> cards = identifier.identifyCards(reduced); return(cards); }
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)); }
public List <Card> process(Image image, Rectangle rect, TableIdentifier parent) { // colors Image reduced = reducer.reduceColors(image); parent.renderImage(reduced, rect); // empty? if (!nearlySameColor(reduced)) { List <Card> cards = identifier.identifyCards(reduced); Log.Fine("found " + cards.Count + " cards"); return(cards); } else { Log.Fine("no cards"); return(new List <Card>()); } }
public int process(Image image, Rectangle[] rects, TableIdentifier parent) { // crop List <Image> images = new List <Image>(); foreach (Rectangle rect in rects) { Image cropped = crop(image, rect); Image reduced = reducer.reduceColors(cropped); images.Add(reduced); parent.renderImage(reduced, rect); } // positions for (int i = 0; i < images.Count; i++) { if (ButtonIdentifier.isReducedButton(images[i])) { return(i); } } throw new Exception("Cannot identify button"); }
public TableControl process(Image image, int position, Rectangle rect, TableIdentifier parent) { // crop image = crop(image, rect); // 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); // ## action ## TableControl.ControlType type = TableControl.ControlType.NONE; if (lines.Count >= 1) { // read chars String actionText = ""; foreach (Image chars in lines[0]) { List <Image> combos = CharDecomposer.decompose(chars, 0); foreach (Image chr in combos) { Image character = ImageCropper.crop(chr); actionText += identifyChars(character); } } if (actionText == "Fold") { type = TableControl.ControlType.FOLD; } else if (actionText == "Check") { type = TableControl.ControlType.CHECK; } else if (actionText.StartsWith("Cal")) { type = TableControl.ControlType.CALL; } else if (actionText == "Bet") { type = TableControl.ControlType.BET; } else if (actionText.StartsWith("Raise")) { type = TableControl.ControlType.RAISE; } else if (actionText.StartsWith("Post")) { type = TableControl.ControlType.POST_BLIND; } } // ## amount ## double amount = 0.0; if (lines.Count >= 2) { // read chars String amountText = ""; foreach (Image chars in lines[1]) { List <Image> combos = CharDecomposer.decompose(chars, 0); foreach (Image chr in combos) { Image character = ImageCropper.crop(chr); amountText += identifyChars(character); } } // format amountText = amountText.Replace("$", "").Replace("?", "").Trim(); // money amount = TextTools.ParseDouble(amountText); } return(new TableControl(type, position, amount)); }
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)); }