Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.7 KiB

  1. //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  2. //
  3. // Copyright (c) 2001 Microsoft Corporation. All rights reserved.
  4. //
  5. // Module:
  6. // volcano/dll/CharRec.h
  7. //
  8. // Description:
  9. // Header for main sequencing of character shape recognizer.
  10. //
  11. // Author:
  12. // hrowley
  13. //
  14. //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  15. #pragma once
  16. // const defintions
  17. #define SYM_UNKNOWN ((SYM)0xFFFF)
  18. // unicode value for space
  19. #define SYM_SPACE 0x0020
  20. // stroke ID corresponding to a space character
  21. #define SPACE_ALT_ID -2
  22. // ratio of avg char hgt above which a gap is considered a space
  23. #define SPACE_RATIO 0.75
  24. ////
  25. //// Data structures
  26. ////
  27. // Settings used to configure recognizer as it is being run.
  28. typedef struct tagRECOG_SETTINGS {
  29. ALC alcValid; // Characters to recognize.
  30. ALC alcPriority; // Characters to prioritize.
  31. UINT partialMode; // Which partial mode are we in.
  32. UINT *pAbort; // Abort address used by partial processing modes.
  33. BYTE *pbAllowedChars; // Bitmask representing which (folded) dense codes are allowed.
  34. BYTE *pbPriorityChars;// Bitmask representing which (folded) dense codes are preferred.
  35. } RECOG_SETTINGS;
  36. // A single stroke of ink.
  37. typedef struct tagSTROKE {
  38. int nInk; // How many points in this stroke
  39. int iBox; // The box containing this stroke
  40. int iOrder; // The index of the first real stroke in this (merged) stroke
  41. int iLast; // The index of the last real stroke in this (merged) stroke
  42. DWORD timeStart, timeEnd; // Range of time indices in this stroke
  43. RECT bbox; // Bounding box of stroke
  44. POINT *pts; // Array of points in the stroke
  45. } STROKE;
  46. // An alternate returned from the shape recognizer.
  47. typedef struct tagRECOG_ALT {
  48. wchar_t wch;
  49. float prob;
  50. } RECOG_ALT;
  51. // Build a copy of the glyph structure.
  52. GLYPH *CopyGlyph(GLYPH *pOldGlyph);
  53. ////
  54. //// Functions
  55. ////
  56. // Load and initialize the databases used.
  57. #ifdef USE_RESOURCES
  58. extern BOOL LoadCharRec(HINSTANCE hInstanceDll);
  59. #else
  60. extern BOOL LoadCharRec(wchar_t *pPath);
  61. #endif
  62. // Unload the databases used.
  63. extern BOOL UnloadCharRec();
  64. // Do shape matching.
  65. extern INT RecognizeChar(
  66. RECOG_SETTINGS *pRecogSettings,// Setting for recognizers.
  67. UINT cStrokes, // Number of strokes to process.
  68. UINT cRealStrokes, // Number of strokes before merging
  69. STROKE *pStrokes, // Array of strokes to process.
  70. FLOAT *pProbIsChar, // Out: probability of being valid char.
  71. UINT maxAlts, // Size of alts array supplied.
  72. RECOG_ALT *pAlts, // Out: alternate list matched.
  73. RECT *pGuideBox, // Guide box for this ink.
  74. int *pCount // Matching space for otter or zilla
  75. );
  76. // Do shape matching.
  77. INT RecognizeCharInsurance(
  78. RECOG_SETTINGS *pRecogSettings,// Setting for recognizers.
  79. UINT cStrokes, // Number of strokes to process.
  80. UINT cRealStrokes, // Number of strokes before merging
  81. STROKE *pStrokes, // Array of strokes to process.
  82. FLOAT *pProbIsChar, // Out: probability of being valid char.
  83. UINT maxAlts, // Size of alts array supplied.
  84. RECOG_ALT *pProbAlts, // Out: alternate list by probs.
  85. int *pnProbAlts,
  86. RECOG_ALT *pScoreAlts, // Out: alternate list by scores
  87. int *pnScoreAlts,
  88. RECT *pGuideBox, // Guide box for this ink.
  89. wchar_t dchContext, // Context (dense code, SYM_UNKNOWN=none)
  90. int *pCount, // Matching space for otter or zilla
  91. VOLCANO_WEIGHTS *pTuneScore, // Component scores for score alternates
  92. BOOL fStringMode, // Whether to use string mode weightings
  93. BOOL fProbMode, // Whether we are in prob mode
  94. void *pvCache, // Recognizer cache, or NULL for unused
  95. int iStroke // Index of last stroke of character
  96. );
  97. // Call the core recognizer for the given character. Returned the
  98. // number of alternates produced, or -1 if an error occurs.
  99. int CoreRecognizeChar(
  100. ALT_LIST *pAltList, // Alt list to be returned
  101. int cAlt, // Max number of alternates
  102. GLYPH **ppGlyph, // Character to recognize (which may be modified)
  103. int nRealStrokes, // Real stroke count for abort processing
  104. RECT *pGuideBox, // Guide box (for partial mode)
  105. RECOG_SETTINGS *pRecogSettings, // partial mode, other settings
  106. CHARSET *pCharSet, // ALCs
  107. int *piRecognizer, // Returns the VOLCANO_CONFIG_* constant for the recognizer used
  108. int *piSpace); // The space number in that recognizer
  109. // Initialize the recognizer partially.
  110. // When iLevel is set to 0, only the locale database, tuning database,
  111. // otter and zilla (and other core recognizers) are loaded.
  112. // When iLevel is set to 1, all the above databases are loaded, as well as
  113. // unigrams and crane/hawk.
  114. BOOL HwxConfigExPartial(wchar_t *pLocale, wchar_t *pRecogDir, int iLevel);