diff options
author | Iliyan Malchev <malchev@google.com> | 2008-10-07 09:05:30 -0700 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2008-10-09 14:27:54 -0700 |
commit | 4fcb47ad848430e96a08a2bae9b5042cf4ed5218 (patch) | |
tree | b5ae67b53e562c4f17372866fd74738b6ee94101 | |
parent | 934b8c63ec54019a8e691b0cf0591aa98680084b (diff) | |
download | tesseract-4fcb47ad848430e96a08a2bae9b5042cf4ed5218.tar.gz |
add tessdata-path cmdline option to tesstest
Signed-off-by: Iliyan Malchev <malchev@google.com>
-rw-r--r-- | ccmain/test.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ccmain/test.cpp b/ccmain/test.cpp index afe252d..10e8e72 100644 --- a/ccmain/test.cpp +++ b/ccmain/test.cpp @@ -25,13 +25,13 @@ BOOL_VAR (tessedit_write_images, FALSE, "Capture the image from the IPE"); int main(int argc, char **argv) { - const char *infile, *outfile, *lang, *ratings; + const char *tessdata, *infile, *outfile, *lang, *ratings; void *buffer; struct stat s; int x, y, bpp, ifd; - FAILIF(argc < 7 || argc > 8, - "tesstest infile xres yres bpp outfile lang [ratings]\n"); + FAILIF(argc < 8 || argc > 9, + "tesstest infile xres yres bpp outfile lang tessdata [ratings]\n"); infile = argv[1]; FAILIF(sscanf(argv[2], "%d", &x) != 1, "could not parse x!\n"); @@ -39,7 +39,8 @@ int main(int argc, char **argv) { FAILIF(sscanf(argv[4], "%d", &bpp) != 1, "could not parse bpp!\n"); outfile = argv[5]; lang = argv[6]; - ratings = argv[7]; + tessdata = argv[7]; + ratings = argv[8]; printf("input file %s\n", infile); ifd = open(infile, O_RDONLY); @@ -49,23 +50,27 @@ int main(int argc, char **argv) { buffer = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, ifd, 0); FAILIF(buffer == MAP_FAILED, "mmap(): %s\n", strerror(errno)); printf("infile mmapped at %p\n", buffer); + FAILIF(tessdata, "You must specify a path for tessdata.\n"); tesseract::TessBaseAPI api; + printf("tessdata %s\n", tessdata); printf("lang %s\n", lang); - FAILIF(api.Init("/sdcard/", lang), "could not initialize tesseract\n"); + FAILIF(api.Init(tessdata, lang), "could not initialize tesseract\n"); if (ratings) { printf("ratings %s\n", ratings); - FAILIF(false == api.ReadConfigFile("/sdcard/tessdata/ratings"), + FAILIF(false == api.ReadConfigFile(ratings), "could not read config file\n"); } printf("set image x=%d, y=%d bpp=%d\n", x, y, bpp); - FAILIF(!bpp || bpp == 2 || bpp > 4, - "Invalid value %d of bpp\n", bpp); + FAILIF(!bpp || bpp == 2 || bpp > 4, + "Invalid value %d of bpp\n", bpp); api.SetImage((const unsigned char *)buffer, x, y, bpp, bpp*x); + printf("set page seg mode to single word\n"); + api.SetPageSegMode(tesseract::PSM_SINGLE_WORD); printf("recognize\n"); char * text = api.GetUTF8Text(); if (tessedit_write_images) { |