classify/blobclass.cpp File Reference

#include "blobclass.h"
#include "fxdefs.h"
#include "variables.h"
#include "extract.h"
#include "efio.h"
#include "callcpp.h"
#include "chartoname.h"
#include <math.h>
#include <stdio.h>
#include <signal.h>

Go to the source code of this file.

Defines

Functions

Variables


Define Documentation

#define FONT_NAME   "UnknownFont"

Definition at line 39 of file blobclass.cpp.

Referenced by InitBlobClassifierVars().

#define MAXCHARNAME   20

used in LearnBlob

Definition at line 76 of file blobclass.cpp.

Referenced by LearnBlob().

#define MAXFILENAME   80

Note:
File: blobclass.cpp
High level blob classification and training routines.
Author:
Dan Johnson
Date:
7/21/89, DSJ, Created.
 ** (c) Copyright Hewlett-Packard Company, 1988.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 74 of file blobclass.cpp.

#define MAXFILENAME   80

Note:
File: blobclass.cpp
High level blob classification and training routines.
Author:
Dan Johnson
Date:
7/21/89, DSJ, Created.
 ** (c) Copyright Hewlett-Packard Company, 1988.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 74 of file blobclass.cpp.

Referenced by LearnBlob().

#define MAXFONTNAME   20

used in LearnBlob

Definition at line 78 of file blobclass.cpp.

#define MAXMATCHES   10

Definition at line 36 of file blobclass.cpp.

#define TRAIN_SUFFIX   ".tr"

used in LearnBlob

Definition at line 80 of file blobclass.cpp.

Referenced by LearnBlob().


Function Documentation

void InitBlobClassifierVars (  ) 

Install blob classifier variables into the wiseowl variable system.

Parameters:
none 
Note:
Globals: FontName name of font being trained on
Returns:
none
Note:
Exceptions: none
Date:
Fri Jan 19 16:13:33 1990, DSJ, Created.

Definition at line 64 of file blobclass.cpp.

References dummy, FONT_NAME, FontName, and string_variable.

Referenced by mfeature_variables().

00064                               { 
00065   VALUE dummy;
00066 
00067   string_variable (FontName, "FontName", FONT_NAME);
00068 
00069 }                                /* InitBlobClassifierVars */

void LearnBlob ( TBLOB Blob,
TEXTROW Row,
char  BlobText[],
int  TextLength 
)

Extract micro-features from the specified blob and append them to the appropriate file.

Parameters:
Blob blob whose micro-features are to be learned
Row row of text that blob came from
BlobText text that corresponds to blob
TextLength number of characters in blob
Note:
Globals:
imagefile Base filename of the page being learned
FontName Name of font currently being trained on
Returns:
none
Note:
Exceptions: none
Date:
7/28/89, DSJ, Created.

Definition at line 97 of file blobclass.cpp.

References chartoname(), cprintf(), Efopen(), EnterLearnMode, ExtractBlobFeatures(), FontName, FreeCharDescription(), GetLineStatsFromRow(), imagefile, MAXCHARNAME, MAXFILENAME, NULL, TRAIN_SUFFIX, and WriteCharDescription().

Referenced by tess_training_tester().

00098 {
00099   static FILE *FeatureFile = NULL;
00100   char Filename[MAXFILENAME];
00101   char CharName[MAXCHARNAME];
00102   CHAR_DESC CharDesc;
00103   LINE_STATS LineStats;
00104 
00105   EnterLearnMode;
00106 
00107   // throw out blobs which do not represent only one character
00108   if (TextLength != 1)
00109     return;
00110 
00111   GetLineStatsFromRow(Row, &LineStats); 
00112 
00113   CharDesc = ExtractBlobFeatures (Blob, &LineStats);
00114 
00115   // if a feature file is not yet open, open it
00116   // the name of the file is the name of the image plus TRAIN_SUFFIX
00117   if (FeatureFile == NULL) {
00118     strcpy(Filename, imagefile); 
00119     strcat(Filename, TRAIN_SUFFIX); 
00120     FeatureFile = Efopen (Filename, "w");
00121 
00122     cprintf ("TRAINING ... Font name = %s.\n", FontName);
00123   }
00124 
00125   // get the name of the character for this blob
00126   chartoname (CharName, BlobText[0], "");
00127 
00128   // label the features with a class name and font name
00129   fprintf (FeatureFile, "\n%s %s ", FontName, CharName);
00130 
00131   // write micro-features to file and clean up
00132   WriteCharDescription(FeatureFile, CharDesc); 
00133   FreeCharDescription(CharDesc); 
00134 
00135 }                                // LearnBlob


Variable Documentation

const char* FontName = FONT_NAME [static]

parameters used to control the training process

Definition at line 48 of file blobclass.cpp.

Referenced by InitBlobClassifierVars(), LearnBlob(), ReadTrainingSamples(), and WriteClusteredTrainingSamples().

char imagefile[]

Image file name

Definition at line 53 of file globals.cpp.


Generated on Wed Feb 28 19:49:18 2007 for Tesseract by  doxygen 1.5.1