Commit Graph

542 Commits

Author SHA1 Message Date
Stefan Weil
f0c9b753c6 BlamerBundle: Add declaration for copy assignment operator
It does not need an implementation as it is currently not used.

This fixes a warning from LGTM:

    No matching copy assignment operator in class BlamerBundle.
    It is good practice to match a copy constructor
    with a copy assignment operator.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-18 15:36:32 +02:00
Stefan Weil
e3658bbc78 C_OUTLINE_FRAG: Add declaration for copy constructor
It does not need an implementation as it is currently not used.

This fixes a warning from LGTM:

    No matching copy constructor in class C_OUTLINE_FRAG.
    It is good practice to match a copy assignment operator
    with a copy constructor.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-18 15:31:45 +02:00
Stefan Weil
5585ed8d85 ROW: Add declaration for copy constructor
It does not need an implementation as it is currently not used.

This fixes a warning from LGTM:

    No matching copy constructor in class ROW.
    It is good practice to match a copy assignment operator
    with a copy constructor.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-18 15:31:10 +02:00
Stefan Weil
a1f0c66be1 BLOB_CHOICE: Add copy assignment operator
This fixes a warning from LGTM:

    No matching copy assignment operator in class BLOB_CHOICE.
    It is good practice to match a copy constructor
    with a copy assignment operator.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-18 15:29:07 +02:00
Stefan Weil
7100a14636 ParamsTrainingHypothesis: Add copy assignment operator
This fixes a warning from LGTM:

    No matching copy assignment operator in class ParamsTrainingHypothesis.
    It is good practice to match a copy constructor
    with a copy assignment operator.

Use also a simpler expression for the size of features.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-18 15:28:12 +02:00
Stefan Weil
0bbd5c5d1c LineHypothesis: Add copy assignment operator
This fixes a warning from LGTM:

    No matching copy assignment operator in class LineHypothesis.
    It is good practice to match a copy constructor
    with a copy assignment operator.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-18 15:23:28 +02:00
Noah Metzger
c13371d6e0 Renamed GetGlyphConfidences() to GetChoices() and glyph_confidences to lstm_choice_mode
Renamed the global attribute glyph_confidences to lstm_choice_mode and the method GetGlyphConfidences() to GetChoices(). All Variables and comments contained in related methods were renamed as well.

Signed-off-by: Noah Metzger <noah.metzger@bib.uni-mannheim.de>
2018-10-17 16:43:39 +02:00
zdenop
e93e8f063f
Merge pull request #1994 from stweil/lgtm
Fix several warnings from LGTM
2018-10-16 18:18:43 +02:00
Stefan Weil
4b800ccaa7 Fix sum computation in higher precision
This also fixes two warnings from LGTM:

    Multiplication result may overflow 'float'
    before it is converted to 'double'.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 18:01:27 +02:00
Stefan Weil
fd84f7b666 LLSQ: Replace sqrt by std::sqrt
This should fix warnings from LGTM:

    Multiplication result may overflow 'float'
    before it is converted to 'double'.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 17:57:26 +02:00
Stefan Weil
7c2af45713 Fix sum computation in higher precision
This also fixes two warnings from LGTM:

    Multiplication result may overflow 'float'
    before it is converted to 'double'.

Replace also FALSE / TRUE by false / true for bool return value.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 17:50:12 +02:00
Stefan Weil
1730b8ccbe classify/cluster: Replace Emalloc by std::vector
This should fix a warning from LGTM:

    Multiplication result may overflow 'int' before it is
    converted to 'unsigned long'.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 17:14:51 +02:00
Stefan Weil
5fb461a563 SVNetwork: Handle failed socket call (CID 1164597)
This fixes a warning from Coverity Scan.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 16:53:24 +02:00
Stefan Weil
2d2b269e02 OpenclDevice: Catch negative index (CID 1395110)
This fixes a warning from CoverityScan.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 16:53:24 +02:00
Stefan Weil
146d2caa9d Classify: Fix new resource leak (CID 1396163)
This fixes a warnings from Coverity Scan.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 16:53:23 +02:00
Stefan Weil
edbd07a5f9 lstmtraining: Handle failed remove syscall (CID 1396166)
This fixes a warning from Coverity Scan.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 16:53:23 +02:00
Stefan Weil
32e1e4b6b4 TessPDFRenderer: Remove unused member variable jpg_quality_ (CID 1396172)
This fixes a warning from Coverity Scan

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 16:53:23 +02:00
Stefan Weil
d89ec15571 Revert "Fix CID 1396172 (Uninitialized members)"
This reverts commit cbd09de7fe.
The variable can be removed as it is not used.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-16 16:53:23 +02:00
Zdenko Podobný
cbd09de7fe Fix CID 1396172 (Uninitialized members) 2018-10-16 12:24:10 +02:00
Stefan Weil
d0d73da65a commontraining: Fix two comments
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-15 11:15:49 +02:00
Zdenko Podobný
10f2c45c00 fix "mkdir -dt" for bds, mac and cygwin 2018-10-14 18:08:50 +02:00
zdenop
524c23de53
Merge pull request #1987 from tfmorris/1986_errno_include
Add missing cerrno includes - fixes #1986
2018-10-13 22:06:00 +02:00
Tom Morris
14af3f720b Add missing cerrno includes - fixes #1986 2018-10-13 16:02:48 -04:00
zdenop
83f80054f6
Merge pull request #1985 from stweil/win32
win32: Show TIFF errors on console
2018-10-13 20:51:26 +02:00
Stefan Weil
6ffb53f815 win32: Show TIFF errors on console
Showing them in a window (default) is not acceptable for a console
application like Tesseract which must be able to work in batch mode.

Such error messages can be triggered by TIFF files which include
vendor specific tags.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-13 20:42:14 +02:00
zdenop
4734317499 fixes #408 - text2image: comma in font name 2018-10-13 15:23:40 +02:00
zdenop
5f4f9372e9 revert debug message commited by mistake 2018-10-13 11:20:25 +02:00
Tom Morris
f6fd9b3a00 Handle null raw_choice - fixes #235, fixes #246 2018-10-13 11:14:26 +02:00
Stefan Weil
de6a759744 unittest: Add paragraphs_test
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-12 16:23:10 +02:00
Stefan Weil
d86d520fd0 Remove tab character in source files
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-12 11:31:10 +02:00
Stefan Weil
d59f14c70a Remove gradechop.h
It only defines the macro partial_split_priority which is only used in
findseam.cpp, so move it to that file.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-12 11:31:10 +02:00
Zdenko Podobný
5fac51173b Merge branch 'master' of https://github.com/tesseract-ocr/tesseract
* 'master' of https://github.com/tesseract-ocr/tesseract:
  remove insight.io badge
  Use env variable in AppVeyor configuration
  Fix integer overflow in overlap calculation
  hocr: add ocrp_wconf to unconditional ocr-capabilities; fixes #1470
  fix uninitialized variable, remove unused variable
  Remove virtual specifiers
2018-10-10 00:38:24 +02:00
Egor Pugin
d93094b397
Merge pull request #1971 from stweil/fix
Fix integer overflow in overlap calculation
2018-10-09 19:59:09 +03:00
Stefan Weil
7f911ac5e0 Fix integer overflow in overlap calculation
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-09 16:43:31 +02:00
zdenop
ca5d285a28 hocr: add ocrp_wconf to unconditional ocr-capabilities; fixes #1470 2018-10-09 16:34:50 +02:00
zdenop
956525f5a4 fix uninitialized variable, remove unused variable 2018-10-09 15:47:20 +02:00
Zdenko Podobný
67b6b02e2d Merge branch 'master' of https://github.com/tesseract-ocr/tesseract
* 'master' of https://github.com/tesseract-ocr/tesseract:
  Remove code for _MSC_VER < 1900
  keep API compatibility with #1265
  Update googletest submodule to release v1.8.1
  Update test submodule
  Always use isascii() with isspace()
  Avoid crash with --psm 0 and LSTM traineddata
  SVPaint: Remove empty block
  Classify: Don't hide debug parameter
  UNICHARMAP: Remove comparison which is always false
  svpaint: Change a variable from global to local
  pgedit: remove unused declaration of display_bln_lines
  Plumbing: Remove comparison which is always false
  Release candidate 2
  use pdf L_FLATE_ENCODE only for png input; fixes #1961
2018-10-09 15:37:40 +02:00
Stefan Weil
128422e75c Remove virtual specifiers
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-09 15:23:59 +02:00
Stefan Weil
f94b3fd9fc Remove code for _MSC_VER < 1900
Tesseract does not support Visual C++ older than Visual Studio 2015.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-09 14:05:21 +02:00
zdenop
c375f4fbf7 keep API compatibility with #1265 2018-10-09 11:22:15 +02:00
zdenop
272ebf995f
Merge pull request #1965 from stweil/isspace
Always use isascii() with isspace()
2018-10-08 18:47:39 +02:00
Stefan Weil
dcd0377bf0 Always use isascii() with isspace()
isspace() must only used with an unsigned char or EOF argument,
and even then its result can depend on the current locale settings.

While this is not a problem for C/C++ executables which use the default
"C" locale, it becomes a problem when the Tesseract API is called from
languages like Python or Java which don't use the "C" locale.

By calling isasci() before calling isspace() this uncertainty can be
avoided, because any locale will hopefully give identical results for
the basic ASCII character set.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 17:25:09 +02:00
Stefan Weil
32e92def49 Avoid crash with --psm 0 and LSTM traineddata
Orientation and script detect only worked with legacy models
and crashed with LSTM models.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 16:03:54 +02:00
Stefan Weil
1eeca175f7 SVPaint: Remove empty block
This fixes a warning from LGTM:

    Empty block without comment

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 14:25:05 +02:00
Stefan Weil
9c857ab962 Classify: Don't hide debug parameter
Fix a warning from LGTM:

    Local variable 'debug' hides a parameter of the same name.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 14:22:31 +02:00
Stefan Weil
30b75cfc05 UNICHARMAP: Remove comparison which is always false
Warning from LGTM:

    Comparison is always false because index <= 0 and 1 <= length.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 14:15:17 +02:00
Stefan Weil
3ae765ecca svpaint: Change a variable from global to local
This fixes a warning from LGTM:

    Poor global variable name 'rgb'. Prefer longer, descriptive
    names for globals (eg. kMyGlobalConstant, not foo).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 13:53:09 +02:00
Stefan Weil
7b5955920d pgedit: remove unused declaration of display_bln_lines
This fixes a warning from LGTM:

    This parameter of type ScrollView is 144 bytes
    - consider passing a pointer/reference instead.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 13:49:59 +02:00
Stefan Weil
ae93b65b1f Plumbing: Remove comparison which is always false
Warning from LGTM:

    Comparison is always false because index >= 0.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-08 13:47:16 +02:00
zdenop
f794571195 use pdf L_FLATE_ENCODE only for png input; fixes #1961 2018-10-07 20:57:19 +02:00
Zdenko Podobný
8598731daf Merge branch 'master' of https://github.com/tesseract-ocr/tesseract
* 'master' of https://github.com/tesseract-ocr/tesseract: (27 commits)
  Rework check for readable input file
  fix "mktemp -d --tmpdir" on Mac OS; see #1453
  pgedit: Change some variables from global to local ones
  improve description of min_characters_to_try variable
  WERD_RES: Remove comparisons which are constant
  GENERIC_2D_ARRAY: Pass parameters by reference
  genericvector: Pass parameters by reference
  chop: Use more efficient float calculations for sqrt
  rect: Use more efficient float calculations for ceil, floor
  intproto: Use more efficient float calculations for floor
  genericvector: Rewrite code to satisfy static code analyzer
  Fix constructor for class Dict (uninitialized member variables)
  Fix use of wrong UNICHARSET
  lstmtraining: Remove dead code for purified model name
  combine_tessdata: Handle failures when extracting
  lstmtraining: Check write permission for output model
  implement parameter min_characters_to_try for minimum characters to try to skip page entirely. fixes #1729
  Merge and enhance documentation on language and script models
  Document some more config options for tesseract
  Add Makefile rule to build HTML manpages
  ...
2018-10-07 15:39:02 +02:00
Stefan Weil
67bf9062df Rework check for readable input file
This reverts commit 1a096441d0 and
implements an alternate check which allows input from stdin.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 22:33:02 +02:00
zdenop
140bfa43f0 Merge branch 'master' of https://github.com/tesseract-ocr/tesseract 2018-10-06 20:50:08 +02:00
zdenop
4044ba8260 fix "mktemp -d --tmpdir" on Mac OS; see #1453 2018-10-06 20:47:48 +02:00
zdenop
c4fb194ba2
Merge pull request #1958 from stweil/lgtm
Fix some warnings from static code analyzer LGTM
2018-10-06 20:27:21 +02:00
Stefan Weil
685abc91f3 pgedit: Change some variables from global to local ones
This fixes compiler warnings and a warning from LGTM:

Poor global variable name 'pe'. Prefer longer, descriptive names [...]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 20:14:20 +02:00
zdenop
424dbd5dc7 improve description of min_characters_to_try variable 2018-10-06 20:10:54 +02:00
Stefan Weil
18f7ab751e WERD_RES: Remove comparisons which are constant
This fixes warnings from LGTM:

Comparison is always false because id >= 0.
Comparison is always true because mirrored >= 1.
Comparison is always false because id >= 0.

INVALID_UNICHAR_ID is -1, so the warnings are correct.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 20:06:38 +02:00
Stefan Weil
238c872753 GENERIC_2D_ARRAY: Pass parameters by reference
This fixes warnings from LGTM:

This parameter of type FontClassInfo is 192 bytes
- consider passing a pointer/reference instead.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 19:48:13 +02:00
Stefan Weil
a7982185c9 genericvector: Pass parameters by reference
This fixes warnings like the following one from LGTM:

This parameter of type ParamsTrainingHypothesis is 112 bytes
- consider passing a pointer/reference instead.

Most parameters can also get the const attribute.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 19:47:49 +02:00
Stefan Weil
819c43d377 chop: Use more efficient float calculations for sqrt
This fixes warnings from LGTM:

Multiplication result may overflow 'float' before it is converted
to 'double'.

While the sqrt function always calculates with double, here the
overloaded std::sqrt can be used to handle the float arguments
more efficiently.

Replace also an old C++ type cast by a static_cast.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 18:59:23 +02:00
Stefan Weil
f264464ec6 rect: Use more efficient float calculations for ceil, floor
This fixes warnings from LGTM:

Multiplication result may overflow 'float' before it is converted
to 'double'.

While the floor function always calculates with double, here the
overloaded std::floor can be used to handle the float arguments
more efficiently.

Replace also old C++ type casts by static_cast.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 18:51:06 +02:00
zdenop
1e4768c1f5
Merge pull request #1957 from stweil/lgtm
Fix some warnings from static code analyzer LGTM
2018-10-06 18:42:12 +02:00
Stefan Weil
b26866bb3b intproto: Use more efficient float calculations for floor
This fixes warnings from LGTM:

Multiplication result may overflow 'float' before it is converted
to 'double'.

While the floor function always calculates with double, here the
overloaded std::floor can be used to handle the float arguments
more efficiently.

Replace also old C++ type casts by static_cast.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 18:29:38 +02:00
Stefan Weil
06a8de0b8b genericvector: Rewrite code to satisfy static code analyzer
Warning from LGTM:

Resource data_ is acquired by class GenericVector<FontSpacingInfo *>
but not released in the destructor.

LGTM complains about data_ not being deleted in the destructor.
The destructor calls the clear() method, but the delete there
was conditional which confuses the static code analyzer.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 18:24:13 +02:00
Stefan Weil
c2a8aa00b8 Fix constructor for class Dict (uninitialized member variables)
wildcard_unichar_id_, apostrophe_unichar_id_, question_unichar_id_ and
slash_unichar_id_ were not initialized in the constructor.

slash_unichar_id_ was used later in a conditional.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 17:52:52 +02:00
zdenop
9efedc15b2
Merge pull request #1954 from stweil/unicharset
Fix use of wrong UNICHARSET
2018-10-06 15:04:31 +02:00
Stefan Weil
8dc9e9fd14 Fix use of wrong UNICHARSET
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 13:21:09 +02:00
Stefan Weil
0e71e5a754 lstmtraining: Remove dead code for purified model name
The purified model name `model_output` was unused,
so remove the comment and the unused code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-06 09:34:17 +02:00
Stefan Weil
f4e982e041 combine_tessdata: Handle failures when extracting
Report an error and terminate if that fails.

Use also EXIT_SUCCESS and EXIT_FAILURE for the return values of main()
and add missing return at end of main().

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-05 21:39:18 +02:00
Stefan Weil
7434590b9a lstmtraining: Check write permission for output model
This is done by creating a temporary file.
Report an error and terminate if that fails.

Use also EXIT_SUCCESS and EXIT_FAILURE for the return values of main().

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-05 20:38:02 +02:00
zdenop
660dbaa9d5 implement parameter min_characters_to_try for minimum characters to try to skip page entirely.
fixes #1729
2018-10-05 19:05:28 +02:00
Stefan Weil
26bfd2b9d3 Allow orientation detection with any traineddata
While orientation and script detection (OSD) normally requires
osd.traineddata to detect both, it must also be possible to do
only orientation detection with eng.traineddata or any other
traineddata.

Enforce osd.traineddata only if there was no `-l` command line option.

Commit 27ce472666 was too restrictive.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-04 17:07:14 +02:00
Zdenko Podobný
dcc50a867f Merge branch 'master' of https://github.com/tesseract-ocr/tesseract
* 'master' of https://github.com/tesseract-ocr/tesseract:
  Fix CID 1164579 (Explicit null dereferenced)
  print help for tesstrain.sh; fixes #1469
  Fix CID 1395882 (Uninitialized scalar variable)
  Fix comments
  Move content of ipoints.h to points.h and remove ipoints.h
  remove duplicate help from combine_lang_model
  Fix typo.
  use tprintf instead of printf to be able disable messages by quiet option (issue #1240)
  add "sudo ldconfig" to install instruction. fixes #1212
  unittest: Replace NULL by nullptr
  unittest: Format code
  tesseract app: check if input file exists; fixes #1023
  Format code (replace ( xxx ) by (xxx))
  Simplify boolean expressions
  Win32: use the ISO C and C++ conformant name "_putenv" instead of deprecated "putenv"
2018-10-03 19:21:42 +02:00
zdenop
423798722f
Merge pull request #1938 from stweil/coverity
Fix two reports from CoverityScan and clean related code
2018-10-02 12:34:08 +02:00
Stefan Weil
04703ca8df Fix CID 1164579 (Explicit null dereferenced)
The report from Coverity Scan is a false positive.

Nevertheless the code can be rewritten and optimized
a little bit to fix that report.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-02 11:48:28 +02:00
Zdenko Podobný
7dbf5a030f print help for tesstrain.sh; fixes #1469 2018-10-02 11:35:10 +02:00
Stefan Weil
9a1f14f2aa Fix CID 1395882 (Uninitialized scalar variable)
The implementation for ICOORD only allows division by scale != 0.

Do the same for FCOORD by asserting that scale != 0.0f,
so undefined program behaviour will be caught.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-02 11:34:14 +02:00
Stefan Weil
ce6ff20939 Fix comments
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-02 11:26:36 +02:00
Stefan Weil
8c56b8f58c Move content of ipoints.h to points.h and remove ipoints.h
Both include files depended on each other, so it did not make sense
to separate them.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-02 11:21:27 +02:00
zdenop
57a6f1d22e remove duplicate help from combine_lang_model 2018-10-01 21:22:51 +02:00
Egor Pugin
6ee7f4eac2
Fix typo. 2018-09-29 17:04:25 +03:00
zdenop
14b83d3090 use tprintf instead of printf to be able disable messages by quiet option
(issue #1240)
2018-09-29 13:49:08 +02:00
zdenop
d5b6222856
Merge pull request #1935 from stweil/style
Format code and fix some style issues
2018-09-29 09:32:56 +02:00
zdenop
1a096441d0 tesseract app: check if input file exists; fixes #1023 2018-09-29 08:51:00 +02:00
Stefan Weil
0f3206d5fe Format code (replace ( xxx ) by (xxx))
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-29 08:21:25 +02:00
Stefan Weil
63f87cac90 Simplify boolean expressions
Remove "? true : false" which is not needed for boolean expressions.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-29 08:21:14 +02:00
Zdenko Podobný
bf6d929e4c fix using c-api / compile with gcc 2018-09-28 23:14:32 +02:00
zdenop
abe40f17c9 Win32: use the ISO C and C++ conformant name "_putenv" instead of deprecated "putenv" 2018-09-28 20:53:57 +02:00
zdenop
a0564fd4ec Allow user to specify dpi for input image 2018-09-28 20:28:52 +02:00
zdenop
345e5ee1f3 prefer to use FreeType for pango_cairo_font_map 2018-09-28 11:07:26 +02:00
zdenop
5fe1390748 remove alpha channel from png: issue #1914 2018-09-27 19:40:15 +02:00
zdenop
971fe50031 fixed #714: use binary mode when generating pdf to stdout on Windows 2018-09-27 18:35:15 +02:00
Zdenko Podobný
5dfce7471c fix #1889: part 2 2018-09-26 09:28:22 +02:00
DevelopAlex
f69af96dbe
Only print "Merging rows..." in debug mode
Only print "Merging rows..." if textord_debug_blob==true (like all the other debug messages).
Otherwise, there are a lot of "Merging rows..." messages in console output.
2018-09-24 11:43:47 +02:00
Zdenko Podobný
01cf7402df add header guard 2018-09-22 18:44:26 +02:00
zdenop
02f9d8d95e
Merge pull request #1923 from stweil/errhandling
Don't trigger a deliberate SIGSEGV for fatal errors in release code
2018-09-20 21:58:45 +02:00
zdenop
63674d3285 Merge branch 'master' of https://github.com/tesseract-ocr/tesseract 2018-09-20 21:58:24 +02:00
Stefan Weil
5338a5a8d5 Don't trigger a deliberate SIGSEGV for fatal errors in release code
The error message "segmentation fault" confuses most users,
so enforce a segmentation fault only in debug code.

Release code simply calls the abort function.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-20 21:50:13 +02:00
zdenop
4ca179d3fa remove condition because fontsize is always > 0 2018-09-20 21:48:44 +02:00
zdenop
cefb62b644
Merge pull request #1920 from stweil/errhandling
Don't call exit when parameter in file is unknown
2018-09-20 10:37:38 +02:00
Stefan Weil
741ea00d70 Don't call exit when parameter in file is unknown
Wrong or old parameters in traineddata files should not terminate
the program, so make that a warning instead of a fatal error.

This fixes issue #1520.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-20 08:37:33 +02:00
Stefan Weil
d586b97854 Remove duplicate include statements
One of them was reported in issue #1843.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-19 22:33:29 +02:00
Zdenko Podobný
5d22fdfeed replace deprecated C++ headers (reported by clan-tidy) - partially supersedes PR #1605 2018-09-18 18:51:11 +02:00
zdenop
62a5e8cfc3
Merge pull request #1265 from picturae/jpg_quality_option
Added JPEG quality option parameter (-c jpg_quality=n)
2018-09-18 11:37:37 +02:00
Jeff Breidenbach
c98391d3d7 fix #1192 bbox as the entire page 2018-09-18 08:09:11 +02:00
David Thornley
92e291250a Fix missing default parameter value cause compile to fail. 2018-09-14 09:56:06 +02:00
David Thornley
31aeb534d9 Fix merge conflicts
Merge branch 'master' into jpg_quality_option

* master: (577 commits)
  fix issue #1889
  Add badges for download , licence and lgtm
  Replace macro MINGW by __MINGW32__
  EquationDetectBase: Define virtual destructor in .cpp file
  BlobGrid: Define virtual destructor in .cpp file
  GridBase: Define virtual destructor in .cpp file
  AlignedBlob: Define virtual destructor in .cpp file
  TransposedArray: Define virtual destructor in .cpp file
  IndexMapBiDi: Define virtual destructor in .cpp file
  Add missing include file (fixes linker error for Visual Studio)
  NthItemTest: Add definition for virtual destructor
  HeapTest: Add definition for virtual destructor
  IcuErrorCode: Define virtual destructor in .cpp file
  Validator: Define virtual destructor in .cpp file
  Dawg: Define virtual destructor in .cpp file
  CUtil: Define virtual destructor in .cpp file
  IndexMap: Define virtual destructor in .cpp file
  CCUtil: Define virtual destructor in .cpp file
  MATRIX: Define virtual destructor in .cpp file
  CCStruct: Define virtual destructor in .cpp file
  ...
2018-09-13 16:03:24 +02:00
Zdenko Podobný
59e42fcef6 fix issue #1889 2018-09-13 07:26:37 +02:00
Stefan Weil
be1393b1e8 Replace macro MINGW by __MINGW32__
MINGW is no longer used and now removed from configure.ac.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 16:05:27 +02:00
Stefan Weil
4fa2a34577 EquationDetectBase: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/textord/equationdetectbase.h:32:7: warning:
 'EquationDetectBase' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 13:14:29 +02:00
Stefan Weil
f29a949649 BlobGrid: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/textord/blobgrid.h:33:7: warning:
 'BlobGrid' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 13:12:29 +02:00
Stefan Weil
b3206d94b5 GridBase: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/textord/bbgrid.h:53:7: warning:
 'GridBase' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 13:11:35 +02:00
Stefan Weil
677198e399 AlignedBlob: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/textord/alignedblob.h:81:7: warning:
 'AlignedBlob' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 13:10:44 +02:00
Stefan Weil
c9d8e5e8bf TransposedArray: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/lstm/weightmatrix.h:33:7: warning:
 'TransposedArray' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 13:09:49 +02:00
Stefan Weil
94d227bc77 IndexMapBiDi: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/ccutil/indexmapbidi.h:102:7: warning:
 'IndexMapBiDi' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 13:08:29 +02:00
Stefan Weil
319de30814 Add missing include file (fixes linker error for Visual Studio)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 12:22:57 +02:00
Stefan Weil
46d2273e82 IcuErrorCode: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/training/icuerrorcode.h:44:7: warning:
 'IcuErrorCode' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 12:11:23 +02:00
Stefan Weil
68bcd6ba90 Validator: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/training/validator.h:72:7: warning:
 'Validator' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:48:43 +02:00
Stefan Weil
0d211f9ed5 Dawg: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/dict/dawg.h:119:7: warning:
 'Dawg' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:47:29 +02:00
Stefan Weil
ac8afc57bb CUtil: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/cutil/cutil_class.h:27:7: warning:
 'CUtil' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:46:31 +02:00
Stefan Weil
32098b7d4d IndexMap: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/ccutil/indexmapbidi.h:102:7: warning:
 'IndexMapBiDi' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:45:28 +02:00
Stefan Weil
5b8162f0ef CCUtil: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/ccutil/ccutil.h:51:7: warning:
 'CCUtil' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:44:27 +02:00
Stefan Weil
14c23c9f13 MATRIX: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/ccstruct/matrix.h:575:7: warning:
 'MATRIX' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:43:17 +02:00
Stefan Weil
bde8f08003 CCStruct: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/ccstruct/ccstruct.h:25:7: warning:
 'CCStruct' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:42:06 +02:00
Stefan Weil
8317371f24 LTRResultIterator 2018-09-04 07:39:34 +02:00
Stefan Weil
b612c2c53d SVEventHandler 2018-09-04 07:39:20 +02:00
Stefan Weil
1c9bd51de8 SVEventHandler: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/viewer/scrollview.h:86:7: warning:
 'SVEventHandler' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:35:30 +02:00
Stefan Weil
8e55146938 MutableIterator: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/ccmain/mutableiterator.h:44:7: warning:
 'MutableIterator' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:35:30 +02:00
Stefan Weil
d926655cfe LTRResultIterator: Define virtual destructor in .cpp file
This fixes compiler warnings from clang:

src/ccmain/ltrresultiterator.h:48:16: warning:
 'LTRResultIterator' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:35:30 +02:00
Stefan Weil
c635cdf5d5 Do not define or use macro __UNIX__
Either it was not needed, or it could be replaced by checking
for not _WIN32.

This fixes a compiler warning from clang:

src/ccutil/platform.h:41:9: warning:
 macro name is a reserved identifier [-Wreserved-id-macro]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-04 07:34:11 +02:00
Stefan Weil
9f8ed31a26 api/pdfrenderer.cpp: Fix compiler warning
Compiler warning from clang:

src/api/pdfrenderer.cpp:848:28: warning:
 cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 12:32:35 +02:00
Stefan Weil
08e25d41b7 textord/cjkpitch: Fix mismatch between format string and argument
size_t would require a different format string. Here an unsigned int
is sufficient in both cases, so use that.

This error was found by lgtm, see
https://lgtm.com/projects/g/tesseract-ocr/tesseract/.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 12:17:47 +02:00
Stefan Weil
2cc7839af7 textord/makerow.cpp: Fix compiler warnings
Compiler warnings from clang:

src/textord/makerow.cpp:2579:36: warning:
 cast from 'const void *' to 'BLOBNBOX **' drops const qualifier [-Wcast-qual]
src/textord/makerow.cpp:2581:36: warning:
 cast from 'const void *' to 'BLOBNBOX **' drops const qualifier [-Wcast-qual]
src/textord/makerow.cpp:2601:31: warning:
 cast from 'const void *' to 'TO_ROW **' drops const qualifier [-Wcast-qual]
src/textord/makerow.cpp:2603:31: warning:
 cast from 'const void *' to 'TO_ROW **' drops const qualifier [-Wcast-qual]
src/textord/makerow.cpp:2623:31: warning:
 cast from 'const void *' to 'TO_ROW **' drops const qualifier [-Wcast-qual]
src/textord/makerow.cpp:2625:31: warning:
 cast from 'const void *' to 'TO_ROW **' drops const qualifier [-Wcast-qual]

Warning from lgtm:

Local variable 'blob' hides a parameter of the same name.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 12:05:56 +02:00
Stefan Weil
e74c88a4d3 ccstruct/werd.cpp: Fix compiler warnings
Compiler warnings from clang:

src/ccstruct/werd.cpp:128:4: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/werd.cpp:394:18: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/werd.cpp:394:27: warning:
 cast from 'const void *' to 'WERD **' drops const qualifier [-Wcast-qual]
src/ccstruct/werd.cpp:395:18: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/werd.cpp:395:27: warning:
 cast from 'const void *' to 'WERD **' drops const qualifier [-Wcast-qual]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 11:42:59 +02:00
Stefan Weil
4934b2e8eb ccstruct/polyblk.cpp: Fix compiler warnings
Compiler warnings from clang:

src/ccstruct/polyblk.cpp:194:16: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:195:16: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:292:45: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:30:9: warning:
 macro is not used [-Wunused-macros]
src/ccstruct/polyblk.cpp:348:8: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:358:12: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:362:26: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:383:21: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:383:36: warning:
 cast from 'const void *' to 'ICOORDELT **' drops const qualifier [-Wcast-qual]
src/ccstruct/polyblk.cpp:384:21: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/polyblk.cpp:384:36:
 warning: cast from 'const void *' to 'ICOORDELT **' drops const qualifier [-Wcast-qual]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 11:42:59 +02:00
Stefan Weil
4f32b8fd05 ccstruct/ocrblock.cpp: Fix compiler warnings
Compiler warnings from clang:

src/ccstruct/ocrblock.cpp:74:12: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/ocrblock.cpp:74:21: warning:
 cast from 'const void *' to 'ROW **' drops const qualifier [-Wcast-qual]
src/ccstruct/ocrblock.cpp:75:16: warning:
 cast from 'const void *' to 'ROW **' drops const qualifier [-Wcast-qual]
src/ccstruct/ocrblock.cpp:75:7: warning:
 use of old-style cast [-Wold-style-cast]

Make also the function decreasing_top_order a local function as it is
only used locally and remove its global declarations (2 locations).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 11:42:59 +02:00
Stefan Weil
59b637efcf ccstruct/mod128.cpp: Fix compiler warnings
Compiler warnings from clang:

src/ccstruct/mod128.cpp:57:15: warning:
 no previous extern declaration for non-static variable 'dirtab' [-Wmissing-variable-declarations]
src/ccstruct/mod128.cpp:57:24: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/mod128.cpp:57:35: warning:
 cast from 'const short *' to 'ICOORD *' drops const qualifier [-Wcast-qual]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 11:42:59 +02:00
Stefan Weil
2a61f6dfcd Fix compiler warnings in c_blob_comparator and make it a local function
Compiler warnings from clang:

src/ccstruct/genblob.cpp:34:20: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/genblob.cpp:34:32: warning:
 cast from 'const void *' to 'C_BLOB **' drops const qualifier [-Wcast-qual]
src/ccstruct/genblob.cpp:35:20: warning:
 use of old-style cast [-Wold-style-cast]
src/ccstruct/genblob.cpp:35:32: warning:
 cast from 'const void *' to 'C_BLOB **' drops const qualifier [-Wcast-qual]

The function c_blob_comparator is only used in fixspace.cpp,
so move it to that file, make it a local function, and remove
genblob.cpp and genblob.h which are no longer needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-09-03 10:59:11 +02:00
Stefan Weil
69a111a739 Clean use of qsort function sort_floats
It is only used in textord/topitch.cpp, so move it into that file.

Remove also the inline attribute as it has not effect here and
update the type casts to fix some compiler warnings from clang.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-31 23:17:27 +02:00
Shree Devi Kumar
70daecf267 Javanese Validation works now - for the most part 2018-08-27 21:00:35 +00:00
Shree Devi Kumar
3e8e338c06 taking as kCOnsonant in validate_grapheme 2018-08-27 12:09:34 +00:00
Shree Devi Kumar
a6c6b34bac Workaround for Javanese Aksara's Taling, do not label it as a combiner 2018-08-27 12:09:34 +00:00
Noah Metzger
f7663c69f6 Added detailed value description for glyph_confidences parameter
Signed-off-by: Noah Metzger <noah.metzger@bib.uni-mannheim.de>
2018-08-27 10:52:15 +02:00
Stefan Weil
7a2f8d9010 Move class tesseract::File from training to ccutil
This allows using the class for unittests, too.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-25 18:16:46 +02:00
Stefan Weil
f24426cd1b Convert CRLF line endings to LF
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-23 18:18:15 +02:00
Stefan Weil
63965bd750 Fix new whitespace issues
- add linefeed after last line
- remove blanks at line endings

This fixes some warnings from clang:

src/training/validate_javanese.h:63:51: warning:
 no newline at end of file [-Wnewline-eof]
src/training/validate_javanese.cpp:269:26: warning:
 no newline at end of file [-Wnewline-eof]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-23 18:18:15 +02:00
Stefan Weil
b08966addf Fix assertion caused by access to default TBOX
Instead of adding an empty TBOX at the end of the box list,
that corner case is now handled by passing a nullptr (like
it was already done for the first box in the list).

This avoids the calls of BoxMissMetric with a TBOX
which raises an assertion there (b == 0).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-22 21:40:26 +02:00
Stefan Weil
7910a766fa Fix CID 1164567 (Dereference after null check)
It looks like the check cblob_ptr != nullptr is not needed.
If cblob_ptr were NULL, we would have seen crashes in compute_bounding_box.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-22 13:55:37 +02:00
Stefan Weil
f3c7a17df3 Fix CID 1395108 (Dereference after null check)
Let's hope that word->best_choice is never NULL.
Overwise both the old and the new code would abort with SIGSEGV.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-22 13:55:37 +02:00