---------------------------------------------------------------------------*/ * This routine performs cleanup operations * on the adaptive classifier. It should be called * before the program is terminated. Its main function * is to save the adapted templates to a file. * * Globals: * - #AdaptedTemplates current set of adapted templates * - #classify_save_adapted_templates TRUE if templat
| 454 | * @note History: Tue Mar 19 14:37:06 1991, DSJ, Created. |
| 455 | */ |
| 456 | void Classify::EndAdaptiveClassifier() { |
| 457 | STRING Filename; |
| 458 | FILE *File; |
| 459 | |
| 460 | if (AdaptedTemplates != NULL && |
| 461 | classify_enable_adaptive_matcher && classify_save_adapted_templates) { |
| 462 | Filename = imagefile + ADAPT_TEMPLATE_SUFFIX; |
| 463 | File = fopen (Filename.string(), "wb"); |
| 464 | if (File == NULL) |
| 465 | cprintf ("Unable to save adapted templates to %s!\n", Filename.string()); |
| 466 | else { |
| 467 | cprintf ("\nSaving adapted templates to %s ...", Filename.string()); |
| 468 | fflush(stdout); |
| 469 | WriteAdaptedTemplates(File, AdaptedTemplates); |
| 470 | cprintf ("\n"); |
| 471 | fclose(File); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | if (AdaptedTemplates != NULL) { |
| 476 | free_adapted_templates(AdaptedTemplates); |
| 477 | AdaptedTemplates = NULL; |
| 478 | } |
| 479 | if (BackupAdaptedTemplates != NULL) { |
| 480 | free_adapted_templates(BackupAdaptedTemplates); |
| 481 | BackupAdaptedTemplates = NULL; |
| 482 | } |
| 483 | |
| 484 | if (PreTrainedTemplates != NULL) { |
| 485 | free_int_templates(PreTrainedTemplates); |
| 486 | PreTrainedTemplates = NULL; |
| 487 | } |
| 488 | getDict().EndDangerousAmbigs(); |
| 489 | FreeNormProtos(); |
| 490 | if (AllProtosOn != NULL) { |
| 491 | FreeBitVector(AllProtosOn); |
| 492 | FreeBitVector(AllConfigsOn); |
| 493 | FreeBitVector(AllConfigsOff); |
| 494 | FreeBitVector(TempProtoMask); |
| 495 | AllProtosOn = NULL; |
| 496 | AllConfigsOn = NULL; |
| 497 | AllConfigsOff = NULL; |
| 498 | TempProtoMask = NULL; |
| 499 | } |
| 500 | delete shape_table_; |
| 501 | shape_table_ = NULL; |
| 502 | if (static_classifier_ != NULL) { |
| 503 | delete static_classifier_; |
| 504 | static_classifier_ = NULL; |
| 505 | } |
| 506 | } /* EndAdaptiveClassifier */ |
| 507 | |
| 508 | |
| 509 | /*---------------------------------------------------------------------------*/ |
nothing calls this directly
no test coverage detected