ApplesauceOS
Read Markdown ↗Download .md

ocr

Read text from the screen or an image.

js
ocr(options = {})

Arguments

ArgumentTypeMeaning
options.imagestringOptional image path; missing/unreadable files fall back to the screen. Check fileExists when a file is required.
options.levelnumber0 = accurate (default), 1 = fast.
options.languagesstring[]Optional supported language codes.
options.coordinatesstring"points" by default; use "pixels" for touch coordinates.
options.regionobjectOptional {x,y,width,height} in the chosen coordinate units.

Returns

[results, null] or [null, errorString]. Each result has text, confidence and rectangle: {x,y,width,height,topLeft,topRight,bottomLeft,bottomRight}. Empty results are successful.

Example

js
const [items, error] = ocr({level: 0, coordinates: "pixels"});
if (error) throw new Error(error);
for (const item of items) console.log(item.text, JSON.stringify(item.rectangle));

Notes

Result rectangles already include crop offsets. Do not add them again. Use the same image geometry as the current screen; OCR text can be wrong.

All JavaScript APIs · Automation playbook