This example VI shows how to use the IMAQ Train OCR function to programmatically train OCR characters and save them to a character set file for later use.
Typically, when using LabVIEW for an Optical Character Recognition (OCR) application, you would begin by using a set of sample images and the OCR Training tool available with the NI Vision Development Module to create a character set file that would later be used to read characters in images. This Community Example shows how you can avoid that process by using the IMAQ Train OCR function to programmatically train characters and add them to a character set file. This method adds flexibility to your OCR code by avoiding (or augmenting) the use of a static character set file.
This example is intended to show how the IMAQ Train OCR function is used, and therefore only trains and subsequently performs OCR on a single image. The example will open a training image from file, perform an initial OCR read (which results in all unknown characters), then asks the user to identify what character, if any, each detected particle in the image represents. After training all detected particles, a second OCR read is performed; this time, the OCR read is able to identify each character as the user trained it. Finally, the newly trained character set is saved to a new character set file.
Note that this code should work for images other than the one provided, but the number and quality of particles detected may vary depending on the image contrast. The settings input for the IMAQ Count Objects 2 function may need to be altered to detect all particles in your image.
LabVIEW Base Development System 2012 (or compatible)
NI Vision Development Module 2012 (or compatible)
No hardware is necessary to use this example VI
Steps to Implement or Execute Code
Download and open the attached file
Run the program
Additional Information or References
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**