| Customize Help

Steps to read dot-matrix strings from an image

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

  1. Allocate a SureDotOCR context, using MdmrAlloc().

  2. Allocate a SureDotOCR result buffer to hold the results of the read operation, using MdmrAllocResult().

  3. Import one or more fonts to the context, using MdmrImportFont(). Typically, you should interactively create your fonts using the console-based font utilities with the predefined SureDotOCR font files that MIL installs.

    You can also add an empty font to the context, using MdmrControl(), and you can add characters to a font by defining their representation in an array, using MdmrControlFont().

  4. Add one or more string models to the context, using MdmrControl().

  5. Set the diameter of the dots that make up the characters in the strings to read, using MdmrControl().

  6. Set the dimensions of the rectangular region in which to read strings, using MdmrControl().

  7. Set the maximum and minimum number of characters in the string model, using MdmrControlStringModel().

  8. If necessary, modify context settings, using MdmrControl(). For example, you can modify the foreground with which to read strings.

  9. If necessary, add or replace characters in a font, using MdmrImportFont() or MdmrControlFont(). MdmrControlFont() provides additional functionality, such as allowing you to delete characters, or rename them.

  10. If necessary, modify string model settings, using MdmrControlStringModel(). For example, you can apply grammar-like constraints, such as specifying that a position in a string must contain a specific character from a specific font.

  11. Preprocess the SureDotOCR context, using MdmrPreprocess().

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

  13. Retrieve the required results from the SureDotOCR result buffer, using MdmrGetResult().

  14. If necessary, draw the results, using MdmrDraw(). For example, you can specify M_DRAW_STRING_BOX to draw a bounding box around the string; then, specify M_DRAW_MIL_FONT_STRING to draw an annotation of the string under the bounding box. For more information on annotation, see the Annotations subsection of the Results and annotations section later in this chapter.

  15. If necessary, save your SureDotOCR context, using MdmrSave() or MdmrStream().

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