/*---------------------------------------------------------------------------*/ int AddAdaptedClass(ADAPT_TEMPLATES Templates, ADAPT_CLASS Class, CLASS_ID ClassId) { /* ** Parameters: ** Templates set of templates to add new class to ** Class new class to add to templates ** ClassId class id to associate with new class ** Globals: none ** Operation: This routine adds a new adapted class to an existing ** set of adapted templates. ** Return: The class index of the new class. ** Exceptions: none ** History: Thu Mar 14 13:06:09 1991, DSJ, Created. */ INT_CLASS IntClass; CLASS_INDEX ClassIndex; assert (Templates != NULL); assert (Class != NULL); assert (LegalClassId (ClassId)); assert (UnusedClassIdIn (Templates->Templates, ClassId)); assert (Class->NumPermConfigs == 0); IntClass = NewIntClass (1, 1); ClassIndex = AddIntClass (Templates->Templates, ClassId, IntClass); assert (Templates->Class[ClassIndex] == NULL); Templates->Class[ClassIndex] = Class; return (ClassIndex); } /* AddAdaptedClass */
// Displays classification as the given shape_id. Creates as many windows // as it feels fit, using index as a guide for placement. Adds any created // windows to the windows output and returns a new index that may be used // by any subsequent classifiers. Caller waits for the user to view and // then destroys the windows by clearing the vector. int TessClassifier::DisplayClassifyAs( const TrainingSample& sample, Pix* page_pix, int unichar_id, int index, PointerVector<ScrollView>* windows) { int shape_id = unichar_id; if (GetShapeTable() != NULL) shape_id = BestShapeForUnichar(sample, page_pix, unichar_id, NULL); if (shape_id < 0) return index; if (UnusedClassIdIn(classify_->PreTrainedTemplates, shape_id)) { tprintf("No built-in templates for class/shape %d\n", shape_id); return index; } classify_->ShowBestMatchFor(shape_id, sample.features(), sample.num_features()); return index; }
/** * This routine adds a new adapted class to an existing * set of adapted templates. * * @param Templates set of templates to add new class to * @param Class new class to add to templates * @param ClassId class id to associate with new class * * @note Globals: none * @note Exceptions: none * @note History: Thu Mar 14 13:06:09 1991, DSJ, Created. */ void AddAdaptedClass(ADAPT_TEMPLATES Templates, ADAPT_CLASS Class, CLASS_ID ClassId) { INT_CLASS IntClass; assert (Templates != NULL); assert (Class != NULL); assert (LegalClassId (ClassId)); assert (UnusedClassIdIn (Templates->Templates, ClassId)); assert (Class->NumPermConfigs == 0); IntClass = NewIntClass (1, 1); AddIntClass (Templates->Templates, ClassId, IntClass); assert (Templates->Class[ClassId] == NULL); Templates->Class[ClassId] = Class; } /* AddAdaptedClass */