The Text Recognition transform extracts strings from an ROI of the image using OCR and delivers it as a numeric or ASCII message signal. Before Text Recognition can be used in the test environment, the character font file needs to be created. MxVision™ allows for basic font file creation. If it is not sufficient, use of the provided National Instruments Font Training Utility is required.

A clear, sharp, focused image is essential for all Image Recognition applications, and it is more important for text recognition. For successful set up, the character string should be in a horizontal line, with characters large enough to be distinguishable. Ideally, for the simple configuration, the characters should not touch. The Region of Interest should not include anything other than characters and the uniform background.

Example of a bad image for text recognition: bad text focus

Example of a good image for text recognition: good text focus

To set up Text Recognition, create a full image that will show characters to be recognized. Usually multiple images are required, and in most applications multiple images of the same character are beneficial for character recognition.  Place the full images under the "Full_Image" directory.

1.Make sure the Camera transform is set up.

2.In MxTransIt, add the Image Recognition transform by selecting it from the Toolbox.

3.Configure transform properties: Change the Transform name from the default name to the Signal name you would like to see in the MxVDev TestCase. This is the signal name that is added to the signal dictionary.


4.Under Image Recognition Properties, set the Image Recognition Mode to Text Recognition.

5.Also in properties, set the Base Directory Path. The name of the folder should be the name of the signal.

6.Click the 3dots_button button in Configure Image Recognition to bring up the configuration form for this Signal.

7.The first page of the configuration form shows images found in the Full_Image directory under the Base Directory for this signal. If no images are shown, click cancel and make sure that the directory points to the right Base Directory and that the Full_Image folder contains your full images.

8.Select the desired Full Image in the list box on the left and draw a rectangle for the Region of Interest. When you draw the ROI, exclude any other lines and features, but ensure that the region you draw is large enough to encompass possible locations of characters in the other images you analyze. Alternatively, you can input the ROI pixel coordinates manually into the fields on the right. Using the toolbar under the image, you can Zoom In, Zoom Out, and Pan the Image. The Rectangle ROI tool is used to draw or modify the ROI rectangle on the image. You can move the rectangle by clicking in the middle, or drag bounding lines or corners.

Set Region of Interest.  Click to expand.

Set Region of Interest.  Click to expand.


9.After the ROI is selected, create a Sample image by clicking the Add button. A sample image is a version of the full image cropped to the selected ROI. Sample images are used for testing the search algorithm and Pattern creation. You can add a couple different Samples or click 'Add All' to create a Sample image out of all full images.
Note: Do not click OK. Proceed to the next step.

10.Select the Test Pattern Match tab to test the recognition algorithm.

a.First specify the font file. Either browse to an existing file, or input the file name and location for the new file. (The file should be located inside the RecoImages folder under the MxVDev project directory to ensure the relative path stays the same if project is moved to another location on the drive or a different computer.).

b.Next select the type of characters (dark on light or light on dark background) and the minimum score for acceptance level.


Test Pattern Match.  Click to expand.

Test Pattern Match.  Click to expand.


11.Select the desired sample image and Click the Run Test button. All possible characters are identified on the image by drawing a bounding box around them. The result grid shows the recognized characters. If the character was not yet trained, or no other characters in the font file matched the character, a "?" character is returned in its place. Use the "Correct String" box to type in the string shown on the image and click the "Update Font File" button.

12.Repeat step 11 for all images until all characters have been trained.

13.If the algorithm failed to draw a box around the character, or the amount of found characters is different from the image, use the NI OCR Training Interface. (Follow the NI help and tutorial.) The most common options that need to be considered are: 'Reject Particles touching ROI', and 'character size and spacing' (adjust minimum and maximum size and spacing values to match the characters in the image). Once the font file is created, return to this MxTransIt configuration form to finish the set up.

14.Select the Signal Port Properties tab to specify the values to be returned during the test. Check the box next to type of information to return. (The algorithm can return an ASCII string or parse the string and return a numerical value). Set a minimum and maximum value for the signal if its value is numeric.

Signal Port Properties.  Click to expand.

Signal Port Properties.  Click to expand.

15. Click OK. Now you can export transform ports and connect the SourceImage port to the SourceImage port on the camera transform.

Related Topics:

Recognition Modes

Camera Transform

Image Recognition Overview