Skip to content

A .net Standard 2.0 Library for finding the location of words on the desktop.

Notifications You must be signed in to change notification settings

mattkwilson/CMatchOCR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CMatchOCR

This .net Standard 2.0 Library allows you to quickly find the location of words anywhere on the desktop.

screenshot

Features

  • WinRT OCR extended to parse words and their associated bounding boxes out of the generated text
  • Fuzzy string matching using FuzzySharp

Getting Started

To get started clone the repository and build the project. You can then reference the library DLL from your own .net framework or .net core project.

var desktopBounds = Screen.PrimaryScreen.Bounds;
var result = screenTextFinder.FindAll("bitmap", desktopBounds);
// take a screenshot and highlight the results
var bitmap = ScreenshotUtility.Screenshot(desktopBounds);
using(var g = Graphics.FromImage(bitmap)) {
  foreach (var rect in result)
  {
      var r = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
      g.DrawRectangle(new Pen(Color.Red), r);
  }
}
bitmap.Save(screenshotFilePath, System.Drawing.Imaging.ImageFormat.Png);

Requirements

  • Windows 8.1+ (64-bit)
  • .net Framework 4.6.1+
  • .net Core 3.0+

Dependencies

Usage

You could get the bounding rectangle for all of the words that match the search word in the area specified by screenRect on the desktop.

var result = screenTextFinder.FindAll("searchWord", screenRect);

You could get the bounding rectangle for the word which matches the search word and is nearest the center of the area on the desktop specified by the screenRect. This is useful for getting the matching word nearest the gaze position when using eye tracking.

if (TryFindClosest("searchWord", screenRect, out outputRect))
{
    int x = (int)(outputRect.X + outputRect.Width / 2f);
    int y = (int)(outputRect.Y + outputRect.Height / 2f);
    Cursor.Position = new Point(x, y);
}

About

A .net Standard 2.0 Library for finding the location of words on the desktop.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages