Alt1 Sprite based OCR
This library is used to read text in-game.
Sprite based matching
This library works slightly different from other OCR methods as it relies on pixel matching of the characters. This works particularly well with runescape as all characters are simply rendered as sprites. The disadvantage is that every font needs definition files to be read.
Font definitions
In order to read a piece of text you need to supply the font that the text is written with. This package includes several standard fonts (@alt1/ocr/fonts/
). To generate your own, use the @alt1/font-loader
package.
Installation
npm i @alt1/ocr -s
Usage
import * as OCR from "@alt1/ocr";
import * as A1lib from "@alt1/base";
import font from "@alt1/font-loader!@alt1/ocr/fonts/aa_8px_mono.fontmeta.json";
var imgref = A1lib.capture(100,100,400,400);
var imagebuffer=imgref.toData();
var color=[255,255,255];
var text=OCR.findReadLine(imagebuffer,font,[color],100,100);
console.log(text)