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.

99 lines
3.0 KiB

  1. #ifndef _BBOX_FEAT_INCLUDED
  2. #define _BBOX_FEAT_INCLUDED
  3. #include <windows.h>
  4. #include "common.h"
  5. // Bins for the various features
  6. #define OverlapBins 1
  7. //#define OverlapBins 2
  8. #define RatioBins 11
  9. #define StrokeBins 8
  10. #define SpaceBins 1
  11. //#define SpaceBins 5
  12. #define ScoreBins 20
  13. #define CodeRange 65536
  14. #define MatchSpaceRange 64
  15. // All unary feature bins should fall in the range 0<=bin<UnaryFeatureRange
  16. #define UnaryFeatureRange (RatioBins*StrokeBins*SpaceBins)
  17. // All binary feature bins should fall in the range 0<=bin<BinaryFeatureRange
  18. #define BinaryFeatureRange (OverlapBins*RatioBins*StrokeBins*StrokeBins*RatioBins*SpaceBins)
  19. // Maximum number of strokes per character
  20. #define MaxStrokesPerCharacter 32
  21. // Maximum number of strokes per character used by zilla
  22. #define MaxZillaStrokesPerCharacter 29
  23. // Log2 values for probabilities are clipped to the range Log2Range<=val<=0
  24. #define Log2Range -32767
  25. typedef struct tagSTROKE_SET_STATS {
  26. RECT rect;
  27. int space, area;
  28. int iBestPath;
  29. int iBestPathScore;
  30. int recogPenalty;
  31. FLOAT recogScore;
  32. wchar_t recogResult;
  33. } STROKE_SET_STATS;
  34. // Type to hold a log probability (which shouldn't get too big). This should
  35. // be a platform independent type, but I don't know what to use...
  36. typedef int PROB;
  37. typedef __int64 COUNTER;
  38. typedef struct tagINTERVALS {
  39. int numIntervals;
  40. int minRange, maxRange;
  41. int min[MaxStrokesPerCharacter+1];
  42. int max[MaxStrokesPerCharacter+1];
  43. } INTERVALS;
  44. typedef struct tagBBOX_PROB_TABLE {
  45. // __int32 nOtterPrototypes;
  46. // __int32 nZillaPrototypes;
  47. __int16 unarySamples[UnaryFeatureRange];
  48. __int16 binarySamples[BinaryFeatureRange];
  49. // __int8 scorePrototype[1];
  50. // __int16 scoreSamples[MatchSpaceRange*ScoreBins];
  51. // __int16 aspectSamples[CodeRange*RatioBins];
  52. } BBOX_PROB_TABLE;
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. int AspectRatioToFeature(RECT r);
  57. int ScoreToFeature(FLOAT score);
  58. int MatchSpaceScoreToFeature(int nStrokes, FLOAT score, int matchSpace);
  59. void EmptyIntervals(INTERVALS *intervals, int min, int max);
  60. void ExpandIntervalsRange(INTERVALS *intervals, int min, int max);
  61. void RemoveInterval(INTERVALS *intervals, int min, int max);
  62. int TotalRange(INTERVALS *intervals);
  63. int TotalPresent(INTERVALS *intervals);
  64. PROB ClippedLog2(COUNTER num, COUNTER denom);
  65. // Returns the unary feature bin of one range of the ink, from index iStart<=index<iEnd
  66. // The returned bin should be in the range 0<=bin<UnaryFeatureRange
  67. int ComputeUnaryFeatures(STROKE_SET_STATS *stats, int nStrokes);
  68. // Returns the unary feature bin of one range of the ink, from index iStart1<=index<iStart2
  69. // and iStart2<=index<iEnd
  70. // The returned bin should be in the range 0<=bin<BinaryFeatureRange
  71. int ComputeBinaryFeatures(STROKE_SET_STATS *stats1, STROKE_SET_STATS *stats2, int nStrokes1, int nStrokes2);
  72. BBOX_PROB_TABLE *LoadBBoxProbTableFile(wchar_t *pRecogDir, LOAD_INFO *pInfo);
  73. BOOL UnLoadBBoxProbTableFile(LOAD_INFO *pInfo);
  74. BBOX_PROB_TABLE *LoadBBoxProbTableRes(HINSTANCE hInst, int nResID, int nType);
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif