Commit Graph

3961 Commits

Author SHA1 Message Date
Stefan Weil
d33ced1958 Use C++17 compiler if possible
This allows using new features of C++17 conditionally.
Simplify also the code which checks and sets the C++ version.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:32:21 +02:00
Shree
26f4126115 Update documentation for unicharset_extractor 2019-06-16 18:32:12 +02:00
zdenop
ff45801dc5 fix packaging appveyor artifacts 2019-06-16 18:32:03 +02:00
Stefan Weil
6e7dcc12e0 Fix crash in PreloadRenderers with nullptr outputbase
The crash could be triggered by a wrong command line.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:31:50 +02:00
Stefan Weil
b0e0e27abf Fix build for unittests
Commit 29f2cff203 was the wrong fix
for the compiler warnings because it broke the unittest build.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:31:42 +02:00
Stefan Weil
90b12b3afa scanedg: Add const attributes
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:31:10 +02:00
Stefan Weil
fdb3f58c6c unittest: Remove unused methods
This fixes compiler warnings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:31:01 +02:00
Stefan Weil
9b9d4bf0fa Remove EXTERN macro
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:30:54 +02:00
Stefan Weil
927d1b8f9e Remove unused macros
This fixes compiler warnings from clang++ like these ones:

    src/ccutil/params.cpp:34:9: warning: macro is not used [-Wunused-macros]
    src/cutil/oldlist.cpp:67:9: warning: macro is not used [-Wunused-macros]
    src/cutil/oldlist.cpp:68:9: warning: macro is not used [-Wunused-macros]
    src/cutil/oldlist.cpp:78:9: warning: macro is not used [-Wunused-macros]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:30:44 +02:00
Stefan Weil
831a3e6167 configure: Fix cross builds (check for TensorFlow header)
AC_CHECK_FILE does not work in cross builds. Such builds aborted.
Replace it by AC_CHECK_HEADERS. This fixes cross builds.

To enable TensorFlow in cross builds, more work is needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:30:22 +02:00
Stefan Weil
337a467d60 Fix compiler errors for old gcc
Travis CI with gcc 4.8 failed with errors.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:30:09 +02:00
Stefan Weil
4712a5ebd8 Remove some unused functions, constants and variables
This fixes compiler warnings, for example:

    src/ccutil/strngs.cpp:36:11: warning: unused variable 'kMaxDoubleSize' [-Wunused-const-variable]
    src/viewer/svutil.cpp:320:13: warning: unused function 'TessFreeAddrInfo' [-Wunused-function]
    src/ccstruct/werd.cpp:32:19: warning: unused variable 'CANT_SCALE_EDGESTEPS' [-Wunused-const-variable]
    src/textord/bbgrid.cpp:103:10: warning: unused variable 'old_tright' [-Wunused-variable]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:29:59 +02:00
Stefan Weil
38f348627b training: Add missing static attributes
That fixes several warnings from clang++ like the following one:

    src/training/combine_lang_model.cpp:36:1: warning: no previous extern declaration for non-static variable 'FLAGS_lang_is_rtl' [-Wmissing-variable-declarations]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:29:49 +02:00
Stefan Weil
66e5689167 training: Move declarations from cpp files to h file
That fixes several warnings from clang++ like the following one:

    src/training/commontraining.cpp:95:1: warning: no previous extern declaration for non-static variable 'FLAGS_D' [-Wmissing-variable-declarations]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:29:37 +02:00
Stefan Weil
6dfb049ccf featdefs: Add missing include statement
It is needed for PicoFeatureLength. This fixes a compiler warning.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:29:26 +02:00
Stefan Weil
b4a7f51cd6 Add missing static attributes
This fixes lots of compiler warnings like these ones:

    src/api/baseapi.cpp:113:13: warning: no previous extern declaration for non-static variable 'kInputFile' [-Wmissing-variable-declarations]
    src/api/baseapi.cpp:117:13: warning: no previous extern declaration for non-static variable 'kOldVarsFile' [-Wmissing-variable-declarations]
    src/api/baseapi.cpp:97:10: warning: no previous extern declaration for non-static variable 'stream_filelist' [-Wmissing-variable-declarations]
    src/ccmain/equationdetect.cpp:46:10: warning: no previous extern declaration for non-static variable 'equationdetect_save_bi_image' [-Wmissing-variable-declarations]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:29:15 +02:00
Stefan Weil
7f32cb659b bits16: Modernize code
This also fixes warnings like the following one from clang++:

    src/ccmain/pgedit.cpp:114:15: warning: declaration requires a global constructor [-Wglobal-constructors]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:29:05 +02:00
Raphael Graf
d809200b6b Do not link librt on OpenBSD 2019-06-16 18:28:45 +02:00
Stefan Weil
2160ebfd03 unicodes: Optimize code by using constexpr and removing unused globals
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:28:33 +02:00
Stefan Weil
cb6cf802e0 featdefs: Optimize code by using constexpr
This also fixes some warnings from clang++:

    src/classify/featdefs.cpp:47:15: warning: declaration requires a global constructor [-Wglobal-constructors]
    src/classify/featdefs.cpp:57:15: warning: declaration requires a global constructor [-Wglobal-constructors]
    src/classify/featdefs.cpp:66:15: warning: declaration requires a global constructor [-Wglobal-constructors]
    src/classify/featdefs.cpp:75:15: warning: declaration requires a global constructor [-Wglobal-constructors]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:28:23 +02:00
Stefan Weil
a4e1378218 Fix broken build for Leptonica < 1.77
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:28:06 +02:00
Stefan Weil
9e23dc2857 Remove classify/cutoffs.h
It only defined CLASS_CUTOFF_ARRAY and some unused definitions.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:27:57 +02:00
zdenop
8b875c00ad fix '--enable-visibility' build 2019-06-16 18:27:28 +02:00
zdenop
516ada66e8 cmake: respect -DTESSDATA_PREFIX=/path (on linux) 2019-06-16 18:27:18 +02:00
Stefan Weil
227452f872 Replace Tensorflow by TensorFlow
The name is written in camel case, see https://www.tensorflow.org/.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:27:08 +02:00
Stefan Weil
34311b36d9 Fix linking of unittest with Tensorflow
This does not add Tensorflow tests. It only fixes the linker errors.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:26:51 +02:00
Stefan Weil
6c68f08460 Implement check for Tensorflow header file
This looks for one of the header files which are included by Tesseract.
It currently uses a hard coded path which works for Debian / Ubuntu.

Simplify also the rules for linking Tensorflow.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:26:42 +02:00
Stefan Weil
bed089092a Remove "third_party/" in comments and update path names
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:26:28 +02:00
Stefan Weil
b7537e94a0 Support build with Tensorflow
It expects include files in /usr/include/tensorflow.

* Add configure option --with-tensorflow (disabled by default)
* Fix data type tensorflow::int64
* Remove "third_party/" in include statements
* Add dummy implementations for Backward and DebugWeights in TFNetwork
* Add files generated with protoc from tfnetwork.proto
  (so the Tensorflow sources are not needed for the build)
* Update Makefiles

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:26:18 +02:00
Zdenko Podobný
39c800950f cmake: fix tiff linking to executable if tiffio.h is found 2019-06-16 18:26:08 +02:00
Zdenko Podobný
e27a07e0c7 fix missing tiff format 2019-06-16 18:24:24 +02:00
Stefan Weil
0d824a600d lstmtrainer: Set constant kLearningRateDecay at compile time
sqrt(0.5) = 1 / sqrt(2) can be replaced by the macro M_SQRT1_2.

This also fixes a compiler warning:

    src/lstm/lstmtrainer.cpp:51:14: warning: declaration requires a global constructor [-Wglobal-constructors]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:24:12 +02:00
bact
c2e45cffef Update normstrngs_test.cc 2019-06-16 18:23:27 +02:00
bact
cd49b61c67 Fix Thai valid text and add Thai illegal sequences
- Fix a invalid sequence in "valid text" `kScriptText`
- Add two illegal sequence in `kBadlyFormedThaiWords`
2019-06-16 18:23:14 +02:00
Bharat123rox
40216e5a5e Fix bug in max_max_dist 2019-06-16 18:23:01 +02:00
Bharat123rox
a324c88563 Fix LGTM and revert bugfix for later PR 2019-06-16 18:22:50 +02:00
Bharat123rox
5f084891be Fix syntax error 2019-06-16 18:22:34 +02:00
Stefan Weil
26f05b1197 Remove SavePixForCrash and related code
That debugging code uses very much memory and is no longer useful.

    text	   data	    bss	    dec	    hex	filename
     815	      0	 262144	 262959	  4032f	src/ccutil/globaloc.o

Remove also the function err_exit which was only used in ccmain/reject.cpp.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:22:21 +02:00
Stefan Weil
7b4b330176 tprintf: Make code reentrant and use less memory
Reduce the maximum message size from 64 KiB to 2 KiB which still should
be large enought for trace messages.

Create the smaller message on the stack instead of using a global
array to allow reentrancy and to reduce the memory use of Tesseract.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:22:03 +02:00
Stefan Weil
ecd0384a31 configure: Use a hopefully more robust way to fix AX_CHECK_COMPILE_FLAG
The check for -Wno-extra-semi-stmt failed on Linux with clang++-7.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:21:50 +02:00
Bharat123rox
19274eebbb Some LGTM fixes and potential bugfixes 2019-06-16 18:21:36 +02:00
Stefan Weil
0190f398bd Remove local definition of M_PI
It is defined for all platforms when math.h or cmath is included
after defining the macro _USE_MATH_DEFINES.

Define _USE_MATH_DEFINES before any include statement to make sure
that M_PI gets defined. It is not necessary to define it conditionally
only for Windows.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:21:16 +02:00
Stefan Weil
0c70c2a69f configure: Fix for clang++-8 and newer
AX_CHECK_COMPILE_FLAG fails if it is used with -Werror and the compiler
raises error -Wextra-semi-stmt:

    configure:4224: checking whether C++ compiler accepts -mavx
    configure:4243: clang++-8 -c -g -O2 -Wall -Wextra -Wpedantic -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -march=native -Werror -Wno-unused-macros -mavx  conftest.cpp >&5
    conftest.cpp:20:3: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
      ;
      ^
    1 error generated.

Add -Wno-extra-semi-stmt to disable those errors if possible.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:21:04 +02:00
Stefan Weil
2b75680e97 Fix compiler warnings
This fixes lots of warnings related to ERRCODE like the following one:

    src/ccutil/errcode.h:81:15: warning:
      declaration requires a global constructor [-Wglobal-constructors]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-06-16 18:20:32 +02:00
zdenop
315c9ad898
Merge pull request #2493 from jbarlow83/4.1-fix-text2image
[4.1] Fix text2image compilation on C++17 compilers
2019-06-14 20:44:18 +02:00
James R. Barlow
caee962da8 Fix text2image compilation on C++17 compilers
C++17 drops support for `std::random_shuffle`, breaking C++17 compilers
that run to compile text2image.cpp. std::shuffle is valid on C++11
through C++17, so use std::shuffle instead.

Due to the use `std::random_shuffle`, `text2image --render_ngrams`
would not give consistent results for different compilers or platforms.
With the current change, the same random number generator is used for
all platforms and initialized to the same seed, so training output
should be consistent.
2019-06-14 01:26:28 -07:00
zdenop
fe06d3a0b3
Update VERSION 2019-05-29 20:20:27 +02:00
Stefan Weil
3452c8ebee Fix out-of-bounds writes in Classify::ReadNewCutoffs
The function did not correctly read Chinese unichars into the local
Class variable if the locale was set to de_DE.UTF-8 (or other
incompatible locales). That resulted in a wrong ClassId which was
used to write into the Cutoffs array without checking for valid bounds.

On macOS the result was a runtime error in baseapi_test (see GitHub
issue #1250):

    [ RUN      ] TesseractTest.InitConfigOnlyTest
    baseapi_test(21845,0x1134c45c0) malloc: *** error for object 0x927f96c28005e0: pointer being freed was not allocated
    baseapi_test(21845,0x1134c45c0) malloc: *** set a breakpoint in malloc_error_break to debug

Replacing sscanf by std::istringstream fixes that.
Add also an assertion to catch future out-of-bounds writes.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-05-18 13:59:48 +02:00
Stefan Weil
4763f24cbb stringrenderer_test: Get system locale only once
This fixes a runtime exception on macOS.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-05-18 13:59:07 +02:00
Stefan Weil
26c294940d Update abseil submodule to HEAD
Abseil suggests to use the latest code:
https://abseil.io/about/philosophy#we-recommend-that-you-choose-to-live-at-head

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-05-18 13:58:49 +02:00