---------------------------------------------------------------------------*/ * * @param Templates adapted templates to add new config to * @param ClassId class id to associate with new config * @param FontinfoId font information inferred from pre-trained templates * @param NumFeatures number of features in IntFeatures * @param Features features describing model for new config * @param Float
| 1790 | * @note History: Fri Mar 15 08:49:46 1991, DSJ, Created. |
| 1791 | */ |
| 1792 | int Classify::MakeNewTemporaryConfig(ADAPT_TEMPLATES Templates, |
| 1793 | CLASS_ID ClassId, |
| 1794 | int FontinfoId, |
| 1795 | int NumFeatures, |
| 1796 | INT_FEATURE_ARRAY Features, |
| 1797 | FEATURE_SET FloatFeatures) { |
| 1798 | INT_CLASS IClass; |
| 1799 | ADAPT_CLASS Class; |
| 1800 | PROTO_ID OldProtos[MAX_NUM_PROTOS]; |
| 1801 | FEATURE_ID BadFeatures[MAX_NUM_INT_FEATURES]; |
| 1802 | int NumOldProtos; |
| 1803 | int NumBadFeatures; |
| 1804 | int MaxProtoId, OldMaxProtoId; |
| 1805 | int BlobLength = 0; |
| 1806 | int MaskSize; |
| 1807 | int ConfigId; |
| 1808 | TEMP_CONFIG Config; |
| 1809 | int i; |
| 1810 | int debug_level = NO_DEBUG; |
| 1811 | |
| 1812 | if (classify_learning_debug_level >= 3) |
| 1813 | debug_level = |
| 1814 | PRINT_MATCH_SUMMARY | PRINT_FEATURE_MATCHES | PRINT_PROTO_MATCHES; |
| 1815 | |
| 1816 | IClass = ClassForClassId(Templates->Templates, ClassId); |
| 1817 | Class = Templates->Class[ClassId]; |
| 1818 | |
| 1819 | if (IClass->NumConfigs >= MAX_NUM_CONFIGS) { |
| 1820 | ++NumAdaptationsFailed; |
| 1821 | if (classify_learning_debug_level >= 1) |
| 1822 | cprintf("Cannot make new temporary config: maximum number exceeded.\n"); |
| 1823 | return -1; |
| 1824 | } |
| 1825 | |
| 1826 | OldMaxProtoId = IClass->NumProtos - 1; |
| 1827 | |
| 1828 | NumOldProtos = im_.FindGoodProtos(IClass, AllProtosOn, AllConfigsOff, |
| 1829 | BlobLength, NumFeatures, Features, |
| 1830 | OldProtos, classify_adapt_proto_threshold, |
| 1831 | debug_level); |
| 1832 | |
| 1833 | MaskSize = WordsInVectorOfSize(MAX_NUM_PROTOS); |
| 1834 | zero_all_bits(TempProtoMask, MaskSize); |
| 1835 | for (i = 0; i < NumOldProtos; i++) |
| 1836 | SET_BIT(TempProtoMask, OldProtos[i]); |
| 1837 | |
| 1838 | NumBadFeatures = im_.FindBadFeatures(IClass, TempProtoMask, AllConfigsOn, |
| 1839 | BlobLength, NumFeatures, Features, |
| 1840 | BadFeatures, |
| 1841 | classify_adapt_feature_threshold, |
| 1842 | debug_level); |
| 1843 | |
| 1844 | MaxProtoId = MakeNewTempProtos(FloatFeatures, NumBadFeatures, BadFeatures, |
| 1845 | IClass, Class, TempProtoMask); |
| 1846 | if (MaxProtoId == NO_PROTO) { |
| 1847 | ++NumAdaptationsFailed; |
| 1848 | if (classify_learning_debug_level >= 1) |
| 1849 | cprintf("Cannot make new temp protos: maximum number exceeded.\n"); |
nothing calls this directly
no test coverage detected