Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Added option to scale images for better recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
JTinkers committed Apr 7, 2019
1 parent bfe7775 commit eacb9fe
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions ScribeBot/Engine/Wrappers/ScreenWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,26 @@ public static string Recognize(int x, int y, int w, int h)
return engine.Process(image).GetText();
}

/// <summary>
/// Get an area of screen as an array of colors.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="w"></param>
/// <param name="h"></param>
/// <returns>2D array of pixel colors.</returns>
public static ColorContainer[][] GetPixels(int x, int y, int w, int h)
public static string Recognize(int x, int y, int w, int h, float scale = 1)
{
var engine = new TesseractEngine(@"Library Data/Tessdata", "eng", EngineMode.Default);

var image = Native.API.CopyScreenArea(x, y, w, h);

var scaled = new Bitmap(image, new Size((int)(image.Width * scale), (int)(image.Height * scale)));

return engine.Process(scaled).GetText();
}

/// <summary>
/// Get an area of screen as an array of colors.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="w"></param>
/// <param name="h"></param>
/// <returns>2D array of pixel colors.</returns>
public static ColorContainer[][] GetPixels(int x, int y, int w, int h)
{
Bitmap pixels = Native.API.CopyScreenArea(x, y, w, h);

Expand Down

0 comments on commit eacb9fe

Please sign in to comment.