Commit Graph

165 Commits

Author SHA1 Message Date
Robin Watts
6bcb941bcf Avoid tesseract writing Pix out/reading them back.
By default, when we ImageData::SetPix, we write the data out as a
PNG, just to read it back in to get a compressed buffer of data.
We then use this to generate a new Pix.

In builds of Tesseract on systems where we don't have temp files,
writing files out is problematic.

Not only that, but compressing/uncompressing is slow, and on minimal
builds of leptonica, where we've disabled the format writers to reduce
memory footprint, we get no compression anyway.

In such cases, it'd be far nicer just to keep the original Pix as
the internal data.

Also, when recovering the pixmap from the ImageData, if we know we're
only going to read from the data, we can avoid duplicating it and
just use the original. This is exactly the case when GRAPHICS_DISABLED
is set.

So, introduce a TESSERACT_IMAGEDATA_AS_PIX predefine that we can use
to cause the internal data to be a Pix rather than a compressed
buffer.



Given we don't do compression, and they were writing to memory,
this was all just more effort than we needed.

Also, if we're using GRAPHICS_DISABLED, we might as well just
pixCopy rather than pixClone as only the scaler uses this.
2020-05-04 21:01:22 +01:00
Stefan Weil
6f2f310fdf Remove redundant method from class GenericVector
length() is not needed: it can be replaced by size().

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2020-01-18 11:30:14 +01:00
Stefan Weil
cfd39dc2c7 pageres: Fix compiler warnings
clang warnings:

    src/ccstruct/pageres.cpp:903:20: warning:
      implicit conversion from 'int' to 'float' changes value from
      2147483647 to 2147483648 [-Wimplicit-int-float-conversion]
    src/ccstruct/pageres.cpp:904:23:
      warning: implicit conversion from 'int' to 'float' changes value from
      -2147483647 to -2147483648 [-Wimplicit-int-float-conversion]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2020-01-04 09:46:10 +01:00
Stefan Weil
fc84f84b5b Remove Emacs C modeline in comment line 1
Those files are C++, and the wrong modeline is not needed at all.
Remove also some empty descriptions and old history in the comments.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-12-05 13:57:50 +01:00
Stefan Weil
56df8e6e19 Fix some typos in comments (most of them found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-12-02 14:30:13 +01:00
Stefan Weil
b1d449315e automake: Flat build for src/ccstruct
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-26 16:20:46 +01:00
Stefan Weil
ac46b286a4 Fix issue #2748
Commit 94d0f77f56 tried to fix issue #2741
but created a new problem.

This commit should fix both old and new issue.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-08 17:12:20 +01:00
Egor Pugin
2a37f5dd62 Update includes to use <>. 2019-10-29 14:50:11 +03:00
amitdo
2f8884a64e Fix autotools build 2019-10-28 21:23:58 +02:00
amitdo
e1bae15547 Fix #include path of public headers 2019-10-28 19:10:30 +02:00
amitdo
dfede8ac01 Move all public headers to include/tesseract 2019-10-28 18:50:31 +02:00
Stefan Weil
73a38b39d5 quadlsq: Fix warnings from LGTM
Fix two occurrences of this LGTM warning:

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

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-10-18 12:07:54 +02:00
Stefan Weil
7a7704bc94 Extend function BoxFileName to handle more common image names
The function derives the file name for the .box file from an image name.

For training from existing line images, it is useful to directly support
the image names which are commonly used.

While generated images for Tesseract training typically use the name
pattern NAME.tif, other ground truth sets use NAME.bin.png for binarized
or NAME.nrm.png for grayscale images.

BoxFileName is also now a local function as it is only used locally.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-10-05 15:59:56 +02:00
Stefan Weil
6d259ebe44 Remove unneeded compare statement (-Wtautological-unsigned-enum-zero-compare)
This fixes a clang warning:

    src/ccstruct/polyblk.cpp:412:12: warning: result of comparison of
      unsigned enum expression >= 0 is always true
      [-Wtautological-unsigned-enum-zero-compare]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-29 22:13:27 +02:00
Stefan Weil
74d5ce82a6 Remove vecfuncs.cpp and vecfunc.h
Replace the macros which were declared in vecfuncs.h by member functions
and move a function which was only used in chop.cpp to that file.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-25 21:20:03 +02:00
Stefan Weil
994ec697d8 Remove member functions STRING::string and StringParam::string
They were redundant because there exist member functions 'c_str' which do the same.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-23 08:33:08 +02:00
Stefan Weil
8cb677d6a2 Replace STRING arguments for LoadDataFromFile and SaveDataToFile
This is a step to eliminate the proprietary STRING data type
from the public Tesseract API.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-22 20:32:28 +02:00
amitdo
479a7b1ca0 Disabled legacy build: Disable more unneeded code 2019-09-19 19:00:13 +03:00
Stefan Weil
fc6899d898 Fix CID 1164664 (Uninitialized scalar field)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-15 21:52:51 +02:00
Stefan Weil
0c960c3cc5 Fix 1164647 (Uninitialized members)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-15 14:25:48 +02:00
amitdo
994596842e 'Disabled leagcy engine' build: don't include unused header 2019-09-15 12:35:36 +03:00
Egor Pugin
6a9584fbc2
Merge pull request #2650 from stweil/cid
Fix several issues reported by Coverity Scan
2019-09-14 21:18:37 +03:00
Stefan Weil
763f4781e8 Fix CID 1164662 (Uninitialized scalar field)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-14 19:22:56 +02:00
Stefan Weil
1d3ee3b2a7 Fix CID 1164649 (Uninitialized scalar field)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-14 17:37:00 +02:00
Stefan Weil
3127242bcd Fix CID 1164638 (Uninitialized scalar field)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-14 17:18:15 +02:00
Stefan Weil
052f9ca0bc Fix CID 1164634, CID 1164635 (Uninitialized pointer field)
Remove the unused dummy member variables.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-14 17:12:39 +02:00
Stefan Weil
f62a895f74 Remove unused italic, bold in class BLOCK_RES and class WORD_RES
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-14 11:53:58 +02:00
Stefan Weil
ceb8af889e Fix CID 1340276 (Uninitialized scalar field) for class BLOB_CHOICE
xgap_before_ and xgap_after_ are never used, so remove them.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-13 22:15:47 +02:00
Stefan Weil
edba74d64f Fix CID 1400760 (Uninitialized scalar field) for class BLOCK
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-13 21:58:05 +02:00
Stefan Weil
8ff321e41a Fix two issues reported by Coverity Scan and modernize class WERD_RES
Report from Coverity Scan:

    CID 1405560 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
    2. uninit_member: Non-static class member end is not initialized in
    this constructor nor in any functions that it calls.

    CID 1405561 [...]

Modernize and optimize class WERD_RES. This not only fixes the issues
but also reduces the size and eliminates the functions InitNonPointers
and InitPointers.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-13 21:51:36 +02:00
Stefan Weil
913cbe6eae Modernize and optimize BLOBNBOX and remove BLOBNBOX::ConstructionInit
The class no longer uses bit fields. Re-ordering the member variables
avoids holes and reduces the size of BLOBNBOX from 168 to 152 bytes.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-12 09:07:48 +02:00
zdenop
98c7aaa343
Lstm choice ril (#2635)
Lstm choice ril
2019-09-06 19:12:00 +02:00
Stefan Weil
b6933a1082 Use type bool for boolean values in class BLOBNBOX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-03 19:56:59 +02:00
Noah Metzger
c350077b96 Made the lstm_choice mode compatible with the hocr_char_boxes mode
Signed-off-by: Noah Metzger <noah.metzger@bib.uni-mannheim.de>
2019-09-02 11:09:54 +02:00
Noah Metzger
e8b9c10d07 Clean up lstm_choice_mode and cut it down to 2 modes instead of 4
Signed-off-by: Noah Metzger <noah.metzger@bib.uni-mannheim.de>
2019-09-02 11:09:53 +02:00
Stefan Weil
fdf4067296 Fix warnings from LGTM
This fixes three LGTM warnings:

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

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-08-30 22:04:24 +02:00
Stefan Weil
46e2a0f106 Remove more code for builds with disabled legacy engine
Now the Tesseract library no longer includes unused code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-08-13 17:49:10 +02:00
Stefan Weil
bce585286d Remove global array kPolyBlockNames from Tesseract library
It is only used in unittest/layout_test.cc after moving a test from
baseapi_test.cc to that file, so it can be made local.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-08-12 14:33:55 +02:00
Stefan Weil
5bbb7f59a6 Remove structures.*
It only provided the functions new_cell, free_cell which could be replaced by new, delete.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-16 07:03:52 +02:00
Stefan Weil
3621272051 Remove cutil_class.*
It is no longer needed since commit 4523ce9f7d.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-16 07:03:52 +02:00
Stefan Weil
fcfdb7e56f Remove unused include statements
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-15 14:48:31 +02:00
Stefan Weil
a6d723bf10 Replace SVSync::StartThread by std::thread and use std::this_thread::yield
Using yield instead of a sleep makes running imagedata_test much faster.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-15 14:30:51 +02:00
Stefan Weil
93427391c1 Replace SVAutoLock by std::lock_guard
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-15 12:01:28 +02:00
Stefan Weil
36026e3c35 Replace SVMutex by std::mutex
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-15 12:01:28 +02:00
Noah Metzger
f2d685a90f Added CTC-based Symbolchoices.
Signed-off-by: Noah Metzger <noah.metzger@bib.uni-mannheim.de>
2019-07-10 16:34:41 +02:00
Stefan Weil
3bae459823 Use C++-11 code instead of TessCallback for WERD_RES::ConditionalBlobMerge
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-04 16:03:30 +02:00
Stefan Weil
242e1db7fa Use C++-11 code instead of TessCallback for function set_compare_callback
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-04 16:03:30 +02:00
Stefan Weil
ffd8101986 Use C++-11 code instead of TessCallback for function set_clear_callback
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-04 16:03:30 +02:00
Stefan Weil
ded24d0367 ccmain: Use C++-11 code instead of TessCallback1
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-04 16:03:30 +02:00
Stefan Weil
fd001c3ab9 Fix linker error with disabled legacy engine (issue #2532)
Commit 3871caae86 introduced a build
regression when the legacy engine was disabled.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-04 13:47:38 +02:00