| Customize Help

Using a fontless context



Characters have distinct features which distinguish them from one another. The String Reader module can make use of these characteristics to read strings in a target image without making use of a font. To do so, it requires that you use a predefined fontless context. You might choose to use a fontless context over a font-based context in cases where you expect to read strings in images with variable fonts. A fontless context is faster to set up than a font-based one.

To use a fontless context, you need to restore, using MstrRestore(), one of the predefined context files located under the "\Matrox Imaging\contexts\" MIL installation folder. The String Reader module comes with three predefined fontless contexts:

  • "FONTLESS_ANPR.msr". A generic context useful to read a wide variety of licence plate types written in Latin-based alphabets and Arabic numerals.

  • "FONTLESS_EUROPEAN_ANPR.msr". A context useful to read European licence plates.

  • "FONTLESS_MACHINE_PRINT.msr". A special context that reads machine printed characters in Arial, Ocr-B, or other sans-serif fonts.

The String Reader module can only use a fontless context to read uppercase characters and numbers. When using a fontless context, MstrInquire() with M_CONTEXT_TYPE returns M_FONTLESS.

Enabling and disabling characters

When you restore a fontless context, it contains information about all uppercase characters and numbers. By default, the read operation searches the image for this entire range. However, for some applications, it is preferable to search for a subset of these characters, especially when you know one of two similar looking characters will not appear. In a fontless context, characters are not added or deleted; instead, they are enabled or disabled. You can disable characters using MstrControl() with M_DISABLE_CHAR or re-enable them with M_ENABLE_CHAR.

When only a few characters are needed, you can disable all characters (M_DISABLE_CHAR set to M_ALL) and then re-enable the required characters, rather than disabling characters one at a time.

Customizing a fontless context

After you have restored a fontless context, you need to specify the size of the characters to read. Use MstrControl() to specify the following values in pixels:

If the characters vary in size, set the reference height (M_REF_CHAR_SIZE_Y) to the average value of the character set's heights. Then, specify minimum and maximum allowable scale factors based on the reference height with M_STRING_SCALE_MIN_FACTOR and M_STRING_SCALE_MAX_FACTOR.

When setting M_MIN_CHAR_SIZE_X, M_MAX_CHAR_SIZE_X and M_REF_CHAR_THICKNESS, specify the width and thickness that the characters have when they have a height of M_REF_CHAR_SIZE_Y. When the read operation finds characters of a different height, size values are scaled by the ratio between the height found and the reference height.

In the following example, the characters have a reference height of 41 pixels. The widest character, Q, has a width of 20 pixels, the narrowest character, 1, has a width of 11 pixels, and the thickness of the characters is 6 pixels.