Skip to content

Commit

Permalink
win32: Show TIFF warnings on console
Browse files Browse the repository at this point in the history
Showing them in a window (default) is not acceptable for a console
application like Tesseract which must be able to work in batch mode.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jul 16, 2016
1 parent 669c739 commit 896e80d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@
#include "openclwrapper.h"
#include "osdetect.h"

#if defined(_WIN32)

#include <tiffio.h>
#include <windows.h>

static void Win32WarningHandler(const char* module, const char* fmt,
va_list ap) {
if (module != NULL) {
fprintf(stderr, "%s: ", module);
}
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
}

#endif /* _WIN32 */

void PrintVersionInfo() {
char *versionStrP;

Expand Down Expand Up @@ -352,6 +369,11 @@ int main(int argc, char **argv) {
int arg_i = 1;
tesseract::PageSegMode pagesegmode = tesseract::PSM_AUTO;

#if defined(_WIN32)
/* Show libtiff warnings on console (not in GUI). */
TIFFSetWarningHandler(Win32WarningHandler);
#endif /* _WIN32 */

ParseArgs(argc, argv,
&lang, &image, &outputbase, &datapath,
&list_langs, &print_parameters,
Expand Down

0 comments on commit 896e80d

Please sign in to comment.