| Customize Help

Steps to reading a string in an image



The following steps provide a basic methodology for using the MIL String Reader module:

  1. For a font-based context, allocate a String Reader context to hold your string models and fonts, using MstrAlloc(). For a fontless context, restore a predefined context, using MstrRestore().

  2. For a font-based context, add the required fonts to the context and customize them, using MstrControl() and MstrEditFont() respectively. For a fontless context, specify the general characteristics of the characters to search for in the target image, using MstrControl().

  3. Allocate a String Reader result buffer to hold the results of the read operation, using MstrAllocResult().

  4. Add a string model to the String Reader context, using MstrControl() with M_STRING_ADD. Note that you can add more than one string model to the context.

  5. Set the maximum number of strings to read, using MstrControl() with M_STRING_NUMBER.

  6. Set the minimum and maximum number of expected characters for the string models, using MstrControl() with M_STRING_SIZE_MIN and M_STRING_SIZE_MAX.

  7. If necessary, set character constraints, using MstrSetConstraint().

  8. If necessary, adjust general context controls, using MstrControl().

  9. If necessary, limit the area to be read using either a child buffer, using MbufChild...(), or define a rectangular ROI in vector format, using MbufSetRegion(). In addition, you can improve the quality of the image using the functions of some other MIL module (such as the MIL image processing function MimMorphic() with M_TOP_HAT or M_BOTTOM_HAT).

  10. Preprocess the String Reader context, using MstrPreprocess().

  11. If necessary, fix read problems, using MstrExpert().

  12. Perform the read operation in the specified target image, using MstrRead().

  13. Retrieve the required results from the String Reader result buffer, using MstrGetResult().

  14. If necessary, draw the results, using MstrDraw().

  15. If necessary, save your String Reader context, using MstrSave() or MstrStream().

  16. Free all your allocated objects, using MstrFree().

Several String Reader functions require that you pass a null-terminated string array of the required characters. These characters can either be ASCII or Unicode. To specify which, use MstrControl() with M_ENCODING. Whenever you pass a string array, you must ensure that it is of the right type for the encoding scheme selected. For more information, see the Encoding subsection of the Global context settings section later in this chapter.