tesseract  4.00.00dev
merge_unicharsets.cpp File Reference
#include <stdio.h>
#include "unicharset.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

This program reads in a text file consisting of feature samples from a training page in the following format:

   FontName UTF8-char-str xmin ymin xmax ymax page-number
    NumberOfFeatureTypes(N)
      FeatureTypeName1 NumberOfFeatures(M)
         Feature1
         ...
         FeatureM
      FeatureTypeName2 NumberOfFeatures(M)
         Feature1
         ...
         FeatureM
      ...
      FeatureTypeNameN NumberOfFeatures(M)
         Feature1
         ...
         FeatureM
   FontName CharName ...

The result of this program is a binary inttemp file used by the OCR engine.

Parameters
argcnumber of command line arguments
argvarray of command line arguments
Returns
none
Note
Exceptions: none
History: Fri Aug 18 08:56:17 1989, DSJ, Created.
History: Mon May 18 1998, Christy Russson, Revistion started.

Definition at line 23 of file merge_unicharsets.cpp.

23  {
24  // Print usage
25  if (argc < 4) {
26  printf("Usage: %s unicharset-in-1 ... unicharset-in-n unicharset-out\n",
27  argv[0]);
28  exit(1);
29  }
30 
31  UNICHARSET input_unicharset, result_unicharset;
32  for (int arg = 1; arg < argc - 1; ++arg) {
33  // Load the input unicharset
34  if (input_unicharset.load_from_file(argv[arg])) {
35  printf("Loaded unicharset of size %d from file %s\n",
36  input_unicharset.size(), argv[arg]);
37  result_unicharset.AppendOtherUnicharset(input_unicharset);
38  } else {
39  printf("Failed to load unicharset from file %s!!\n", argv[arg]);
40  exit(1);
41  }
42  }
43 
44  // Save the combined unicharset.
45  if (result_unicharset.save_to_file(argv[argc - 1])) {
46  printf("Wrote unicharset file %s.\n", argv[argc - 1]);
47  } else {
48  printf("Cannot save unicharset file %s.\n", argv[argc - 1]);
49  exit(1);
50  }
51  return 0;
52 }
void AppendOtherUnicharset(const UNICHARSET &src)
Definition: unicharset.cpp:439
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:348
bool save_to_file(const char *const filename) const
Definition: unicharset.h:308
int size() const
Definition: unicharset.h:299