- How to use native OCR?
- Language model
- Reading the image or PDF
OCR: Convert an image to text
An OCR (Optical Character Recognition) system analyzes an image to extract the text it contains. From version 26, you can integrate OCR functionalities into your applications and your sites.
The OCR engine is a neural network. It decrypts images containing text.
Take a picture of a contract with your phone, and retrieve the text in Word!
OCR is also very useful for a DMS, in order to index the contents.
To retrieve text via native OCR:
- If necessary, load the model corresponding to the language used.
- Use OCRExtractText, indicating the name of the image or PDF document to be analyzed.
The following language models are provided as standard: English, Spanish and French. The model that corresponds to the current language will be used.
To recognize other languages via native OCR, simply:
- Provide the neural network training model corresponding to the language (".traineddata" file to include in the directory of the executable):
- Use OCRLoadLanguage to load the desired language.
Reading the image or PDF
returns all the text from the image. All content other than text is ignored. If necessary, this function can be used to analyze only a part of an image: simply specify the coordinates of the part to be analyzed.
analyzes an image and returns a set of rectangles each containing a block of text.
- To get the best results possible, it is recommended to:
- Use a high-resolution image.
- Crop the image around the text if possible (avoid unnecessary areas).
- Limit text skew. If the image is slightly skewed, OCR may be able to detect the text, but the quality will be affected.
- Limit the number of models/languages used.
- Note that, if the image used corresponds to an Image control, the source image will be directly manipulated. Therefore, the changes made in the Image control (image size for example) will not be taken into account. To apply these changes, it is necessary to save the image.
- Note that, if the image used (via an Image control or not) is a PDF file, its quality will be set to 300 DPI.
- OCR can only detect printed text. It cannot recognize handwritten text.
Unit examples (WINDEV): OCR functions
[ + ]
This example shows how to use OCR functions in WINDEV.
This page is also available for…