📄 intmatcher.cpp
字号:
UINT8Pointer = (UINT8 *) ProtoEvidence; for (ProtoNum = 0; ProtoNum < NumProtos; ProtoNum++) for (ProtoIndex = 0; ProtoIndex < MAX_PROTO_INDEX; ProtoIndex++, UINT8Pointer++) *UINT8Pointer = 0;}/*---------------------------------------------------------------------------*/voidIMClearFeatureEvidenceTable (UINT8 FeatureEvidence[MAX_NUM_CONFIGS],int NumConfigs) {/* ** Parameters: ** FeatureEvidence Feature Evidence Table ** NumConfigs Number of Configurations ** Globals: ** Operation: ** Clear FeatureEvidence table. ** Return: ** Exceptions: none ** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created. */ register UINT8 *UINT8Pointer; register int ConfigNum; UINT8Pointer = FeatureEvidence; for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++, UINT8Pointer++) *UINT8Pointer = 0;}/*---------------------------------------------------------------------------*/void IMDebugConfiguration(int FeatureNum, UINT16 ActualProtoNum, UINT8 Evidence, BIT_VECTOR ConfigMask, UINT32 ConfigWord) {/* ** Parameters: ** Globals: ** Operation: ** Print debugging information for Configuations ** Return: ** Exceptions: none ** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created. */ cprintf ("F = %3d, P = %3d, E = %3d, Configs = ", FeatureNum, (int) ActualProtoNum, (int) Evidence); while (ConfigWord) { if (ConfigWord & 1) cprintf ("1"); else cprintf ("0"); ConfigWord >>= 1; } cprintf ("\n");}/*---------------------------------------------------------------------------*/void IMDebugConfigurationSum(int FeatureNum, UINT8 *FeatureEvidence, INT32 ConfigCount) {/* ** Parameters: ** Globals: ** Operation: ** Print debugging information for Configuations ** Return: ** Exceptions: none ** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created. */ int ConfigNum; cprintf ("F=%3d, C=", (int) FeatureNum); for (ConfigNum = 0; ConfigNum < ConfigCount; ConfigNum++) { cprintf ("%4d", FeatureEvidence[ConfigNum]); } cprintf ("\n");}/*---------------------------------------------------------------------------*/voidPMUpdateTablesForFeature (INT_CLASS ClassTemplate,int FeatureNum,INT_FEATURE Feature,UINT8 FeatureEvidence[MAX_NUM_CONFIGS],int SumOfFeatureEvidence[MAX_NUM_CONFIGS],int Debug) {/* ** Parameters: ** ClassTemplate Prototypes & tables for a class ** FeatureNum Current feature number (for DEBUG only) ** Feature Pointer to a feature struct ** FeatureEvidence Feature Evidence Table ** SumOfFeatureEvidence Sum of Feature Evidence Table ** ProtoEvidence Prototype Evidence Table ** Debug Debugger flag: 1=debugger on ** Globals: ** Operation: ** For the given feature: prune protos, compute evidence, update Feature Evidence, ** Proto Evidence, and Sum of Feature Evidence tables. ** Return: ** Exceptions: none ** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created. */ UINT8 config_byte; UINT8 proto_byte; UINT8 Evidence; INT32 config_offset; UINT8 *UINT8Pointer; UINT32 ConfigWord; UINT32 ProtoWord; INT32 M3; INT32 A3; UINT32 A4; INT32 proto_word_offset; INT32 proto_offset; UINT32 ProtoNum; UINT32 ActualProtoNum; PROTO_SET ProtoSet; UINT32 *ProtoPrunerPtr; INT_PROTO Proto; int ProtoSetIndex; UINT32 XFeatureAddress; UINT32 YFeatureAddress; UINT32 ThetaFeatureAddress; int *IntPointer; int ConfigNum; IMClearFeatureEvidenceTable (FeatureEvidence, NumIntConfigsIn (ClassTemplate)); /* Precompute Feature Address offset for Proto Pruning */ XFeatureAddress = ((Feature->X >> 2) << 1); YFeatureAddress = (NUM_PP_BUCKETS << 1) + ((Feature->Y >> 2) << 1); ThetaFeatureAddress = (NUM_PP_BUCKETS << 2) + ((Feature->Theta >> 2) << 1); for (ProtoSetIndex = 0, ActualProtoNum = 0; ProtoSetIndex < NumProtoSetsIn (ClassTemplate); ProtoSetIndex++) { ProtoSet = ProtoSetIn (ClassTemplate, ProtoSetIndex); ProtoPrunerPtr = (UINT32 *) ((*ProtoSet).ProtoPruner); for (ProtoNum = 0; ProtoNum < PROTOS_PER_PROTO_SET; ProtoNum += (PROTOS_PER_PROTO_SET >> 1), ActualProtoNum += (PROTOS_PER_PROTO_SET >> 1), ProtoPrunerPtr++) { /* Prune Protos of current Proto Set */ ProtoWord = *(ProtoPrunerPtr + XFeatureAddress); ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress); ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress); if (ProtoWord != 0) { proto_byte = ProtoWord & 0xff; ProtoWord >>= 8; proto_word_offset = 0; while (ProtoWord != 0 || proto_byte != 0) { while (proto_byte == 0) { proto_byte = ProtoWord & 0xff; ProtoWord >>= 8; proto_word_offset += 8; } proto_offset = offset_table[proto_byte] + proto_word_offset; proto_byte = next_table[proto_byte]; /* Compute Evidence */ Proto = &(ProtoSet->Protos[ProtoNum + proto_offset]); ConfigWord = Proto->Configs[0]; A3 = (((Proto->A * (Feature->X - 128)) << 1) - (Proto->B * (Feature->Y - 128)) + (Proto->C << 9)); M3 = (((INT8) (Feature->Theta - Proto->Angle)) * IntThetaFudge) << 1; if (A3 < 0) A3 = ~A3; if (M3 < 0) M3 = ~M3; A3 >>= MultTruncShiftBits; M3 >>= MultTruncShiftBits; if (A3 > EvidenceMultMask) A3 = EvidenceMultMask; if (M3 > EvidenceMultMask) M3 = EvidenceMultMask; A4 = (A3 * A3) + (M3 * M3); A4 >>= TableTruncShiftBits; if (A4 > EvidenceTableMask) Evidence = 0; else Evidence = SimilarityEvidenceTable[A4]; UINT8Pointer = FeatureEvidence - 8; config_byte = 0; while (ConfigWord != 0 || config_byte != 0) { while (config_byte == 0) { config_byte = ConfigWord & 0xff; ConfigWord >>= 8; UINT8Pointer += 8; } config_offset = offset_table[config_byte]; config_byte = next_table[config_byte]; if (Evidence > UINT8Pointer[config_offset]) UINT8Pointer[config_offset] = Evidence; } } } } } if (PrintFeatureMatchesOn (Debug)) IMDebugConfigurationSum (FeatureNum, FeatureEvidence, NumIntConfigsIn (ClassTemplate)); IntPointer = SumOfFeatureEvidence; UINT8Pointer = FeatureEvidence; for (ConfigNum = NumIntConfigsIn (ClassTemplate); ConfigNum > 0; ConfigNum--) *IntPointer++ += (*UINT8Pointer++);}/*---------------------------------------------------------------------------*/voidIMUpdateTablesForFeature (INT_CLASS ClassTemplate,BIT_VECTOR ProtoMask,BIT_VECTOR ConfigMask,int FeatureNum,INT_FEATURE Feature,UINT8 FeatureEvidence[MAX_NUM_CONFIGS],int SumOfFeatureEvidence[MAX_NUM_CONFIGS],UINT8ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],int Debug) {/* ** Parameters: ** ClassTemplate Prototypes & tables for a class ** FeatureNum Current feature number (for DEBUG only) ** Feature Pointer to a feature struct ** FeatureEvidence Feature Evidence Table ** SumOfFeatureEvidence Sum of Feature Evidence Table ** ProtoEvidence Prototype Evidence Table ** Debug Debugger flag: 1=debugger on ** Globals: ** Operation: ** For the given feature: prune protos, compute evidence, update Feature Evidence, ** Proto Evidence, and Sum of Feature Evidence tables. ** Return: ** Exceptions: none ** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created. */ register UINT32 ConfigWord; register UINT32 ProtoWord; register UINT32 ProtoNum; register UINT32 ActualProtoNum; UINT8 proto_byte; INT32 proto_word_offset; INT32 proto_offset; UINT8 config_byte; INT32 config_offset; PROTO_SET ProtoSet; UINT32 *ProtoPrunerPtr; INT_PROTO Proto; int ProtoSetIndex; UINT8 Evidence; UINT32 XFeatureAddress; UINT32 YFeatureAddress; UINT32 ThetaFeatureAddress; register UINT8 *UINT8Pointer; register int ProtoIndex; UINT8 Temp; register int *IntPointer; int ConfigNum; register INT32 M3; register INT32 A3; register UINT32 A4; IMClearFeatureEvidenceTable (FeatureEvidence, NumIntConfigsIn (ClassTemplate)); /* Precompute Feature Address offset for Proto Pruning */ XFeatureAddress = ((Feature->X >> 2) << 1); YFeatureAddress = (NUM_PP_BUCKETS << 1) + ((Feature->Y >> 2) << 1); ThetaFeatureAddress = (NUM_PP_BUCKETS << 2) + ((Feature->Theta >> 2) << 1); for (ProtoSetIndex = 0, ActualProtoNum = 0; ProtoSetIndex < NumProtoSetsIn (ClassTemplate); ProtoSetIndex++) { ProtoSet = ProtoSetIn (ClassTemplate, ProtoSetIndex); ProtoPrunerPtr = (UINT32 *) ((*ProtoSet).ProtoPruner); for (ProtoNum = 0; ProtoNum < PROTOS_PER_PROTO_SET; ProtoNum += (PROTOS_PER_PROTO_SET >> 1), ActualProtoNum += (PROTOS_PER_PROTO_SET >> 1), ProtoMask++, ProtoPrunerPtr++) { /* Prune Protos of current Proto Set */ ProtoWord = *(ProtoPrunerPtr + XFeatureAddress); ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress); ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress); ProtoWord &= *ProtoMask; if (ProtoWord != 0) { proto_byte = ProtoWord & 0xff; ProtoWord >>= 8; proto_word_offset = 0; while (ProtoWord != 0 || proto_byte != 0) { while (proto_byte == 0) { proto_byte = ProtoWord & 0xff; ProtoWord >>= 8; proto_word_offset += 8; } proto_offset = offset_table[proto_byte] + proto_word_offset; proto_byte = next_table[proto_byte]; Proto = &(ProtoSet->Protos[ProtoNum + proto_offset]); ConfigWord = Proto->Configs[0]; A3 = (((Proto->A * (Feature->X - 128)) << 1) - (Proto->B * (Feature->Y - 128)) + (Proto->C << 9)); M3 = (((INT8) (Feature->Theta - Proto->Angle)) * IntThetaFudge) << 1; if (A3 < 0) A3 = ~A3; if (M3 < 0) M3 = ~M3; A3 >>= MultTruncShiftBits; M3 >>= MultTruncShiftBits; if (A3 > EvidenceMultMask) A3 = EvidenceMultMask; if (M3 > EvidenceMultMask) M3 = EvidenceMultMask; A4 = (A3 * A3) + (M3 * M3); A4 >>= TableTruncShiftBits; if (A4 > EvidenceTableMask) Evidence = 0; else Evidence = SimilarityEvidenceTable[A4]; if (PrintFeatureMatchesOn (Debug)) IMDebugConfiguration (FeatureNum, ActualProtoNum + proto_offset, Evidence, ConfigMask, ConfigWord); ConfigWord &= *ConfigMask; UINT8Pointer = FeatureEvidence - 8; config_byte = 0; while (ConfigWord != 0 || config_byte != 0) { while (config_byte == 0) { config_byte = ConfigWord & 0xff; ConfigWord >>= 8; UINT8Pointer += 8; //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -