Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 11.3   11.4   11.5   12.0   12.1   12.2   12.3   12.4   12.5   13.0    Statistic    FMM    Blog  

OCR.SetImage

Provide an image for Tesseract to recognize.

Component Version macOS Windows Linux Server iOS SDK
OCR 2.9 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "OCR.SetImage"; imageRef )   More

Parameters

Parameter Description Example
imageRef The image reference. Use functions like GMImage.NewFromContainer to get an image reference. $img

Result

Returns OK on success.

Description

Provide an image for Tesseract to recognize.
The plugin makes a copy of the image.

Please do not pass PDF files. For PDF you either need to extract image (for scans) or raster PDF pages as images. Our functions PDFKit.GetPDFPageImage or DynaPDF.RenderPage can help here.
If the PDF file contains real text, please use PDFKit.GetPDFText, PDFKit.GetPDFPageText, DynaPDF.ExtractText, DynaPDF.ExtractPageText or DynaPDF.ExtractPageRectText. This will not do OCR, but extract the text directly.

Optionally you can define area of interest with OCR.SetRectangle function.

Examples

Set image reference:

MBS( "OCR.SetImage"; $img )

Load image, apply effect and pass with rectangle:

Set Variable [ $img ; Value: MBS("GMImage.NewFromContainer"; OCR::Image) ]
// apply some effects here like increase contrast
Set Variable [ $r ; Value: MBS( "OCR.SetImage"; $img) ]
Set Variable [ $r ; Value: MBS( "OCR.SetRectangle"; 0; 0; 1000; 400) ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $img) ]

See also

Release notes

Example Databases

Blog Entries

Created 18th August 2014, last changed 15th July 2021


OCR.Recognize - OCR.SetImageContainer

Feedback: Report problem or ask question.


Start Chat