Commit Graph

1543 Commits

Author SHA1 Message Date
James R. Barlow
66c03c9166 Revise after code review 2016-12-11 22:26:05 +01:00
James R. Barlow
bdb690ba06 Implement a new orientation and script detection API for C and C++
See issue #424.

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class.  Generally it won't
be possible for a regular C compiler to do this properly.

It's also assumed that most API level users of Tesseract are only interested in Tesseract's best guess as to script and orientation, not the individual values for all possible scripts.

This introduces a new API with a better name that is more closely aligned with the output of 'tesseract -psm 0'.  Both tesseract -psm 0 and this API now share the same code in baseapi.cpp.
2016-12-11 22:25:59 +01:00
Philipp Nordhus
ba5a17b4ba Remove duplicate destructor
Destructor of base class GenericVector calls base class clear()
method, deallocating the memory.
2016-12-08 15:50:27 +01:00
Zdenko Podobn??
59ba80bb3a More clang-tidy from previous commits
# Conflicts:
#	opencl/opencl_device_selection.h
#	opencl/openclwrapper.cpp
2016-12-08 15:50:22 +01:00
Jeff Breidenbach
d969ed1352 Produce warning for invalid resolution. Fix #453 2016-12-07 22:03:28 +01:00
Stefan Weil
f29abea160 tesseract: Disable Leptonica messages
Disable debugging and informational messages from Leptonica
for release builds.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 21:55:23 +01:00
Zdenko Podobný
f60bfbe55c fix typo 2016-12-07 19:52:18 +01:00
Stefan Weil
e34ab8c3d5 doc: Fix line endings
Remove spaces at line endings and replace CRLF by LF.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:25:24 +01:00
Stefan Weil
ddef7d4a7c training: Update Makefile for current Mingw-w64
Mingw-w64 no longer needs special linker options,
builds with those options fail.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:23:53 +01:00
Ray Smith
2298bdddc5 Fixed damage to binary images when processing PDFs, issue #535 2016-12-07 17:21:58 +01:00
Stefan Weil
4535d24d13 Remove extra semicolons after member function definitions
clang++ report:
api/baseapi.h:852:4: warning:
 extra ';' after member function definition [-Wextra-semi]
[...]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:18:51 +01:00
Stefan Weil
d009c4fc8c opencl: Add missing checks for OpenCL failures
Fix also text for an existing check.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:18:39 +01:00
Stefan Weil
8a02c4f2e9 cube: Fix coverity warning caused by unneeded null pointer check
Commit 03eec61a2f removed unneeded
null pointer checks after new, but missed one which now raises
a warning from coverity scan. Remove that one, too.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:18:25 +01:00
Stefan Weil
98d50f6c16 cube: Fix use after free regression
Coverity report:

CID 1366758:  Memory - corruptions  (USE_AFTER_FREE)
Calling "operator delete[]" frees pointer "label32"
 which has already been freed.

Commit f60ff4d575 fixed several memory leaks
but also added this wrong delete operation.

label32 is assigned to char_samp->label32_, so it is freed when deleting
char_samp.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:18:16 +01:00
Zdenko Podobný
1aaff8872b opencl: Remove unneeded and potentially bad type casts
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:17:49 +01:00
Stefan Weil
6933b0618c Change tesseract parameter -psm to --psm
For compatibility reasons the old variant is still supported.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:12:45 +01:00
Stefan Weil
9984077798 Change tesseract parameter -oem to --oem
It was introduced recently in commit f24ef67d, so there is no need
to support the old variant for compatibility reasons.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:12:37 +01:00
Stefan Weil
4789ca2ab8 Simplify new operations
It is not necessary to check for null pointers after new.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:10:10 +01:00
Stefan Weil
257d6e8156 cube: Simplify new operations
It is not necessary to check for null pointers after new.

Simplify also two delete operations which were missing
in the previous commit.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 17:09:52 +01:00
Zdenko Podobn??
5307204f93 Added std:: to vector 2016-12-07 17:05:01 +01:00
Zdenko Podobný
82529e31dd Formatting changes from clang_tidy on latest pull
# Conflicts:
#	ccutil/host.h
2016-12-07 16:58:25 +01:00
Morten Espersen
b169ef5d34 Correcting link for 3rd party wiki pages 2016-12-07 16:23:06 +01:00
Stefan Weil
73c0649d98 cube/char_samp: Fix some memory leaks
Coverity report:

CID 1164722 (#9 of 9): Resource leak (RESOURCE_LEAK)
20. leaked_storage: Variable label32 going out of scope leaks the storage
 it points to.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 16:22:48 +01:00
Stefan Weil
a2fa9cab36 cube/char_bigrams: Fix some memory leaks
Coverity report:

CID 1164717 (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable upper_32 going out of scope leaks
 the storage it points to.

CID 1164718 (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable lower_32 going out of scope leaks
 the storage it points to.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 16:22:39 +01:00
Stefan Weil
a74c6aa27d cube: Simplify delete operations
It is not necessary to check for null pointers.

Remove also unneeded delete operations and add missing delete operations
in cube/bmp_8.cpp.

Simplify also a conditional statement in cube/cube_object.cpp.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 16:22:26 +01:00
Stefan Weil
ca6e64e2c9 mingw-w64: Fix compiler warnings caused by macro redefinition
GNU compiler report (cross build for Windows on Debian):

In file included from ../ccutil/host.h:63:0,
                 from ../arch/dotproductsse.h:22,
                 from ../arch/dotproductsse.cpp:43:
../ccutil/platform.h:27:0: warning: "NOMINMAX" redefined
 #define NOMINMAX

In file included from /usr/lib/gcc/i686-w64-mingw32/6.1-win32/include/c++/i686-w64-mingw32/bits/c++config.h:495:0,
                 from /usr/lib/gcc/i686-w64-mingw32/6.1-win32/include/c++/cstdlib:41,
                 from /usr/lib/gcc/i686-w64-mingw32/6.1-win32/include/c++/stdlib.h:36,
                 from /usr/lib/gcc/i686-w64-mingw32/6.1-win32/include/mm_malloc.h:27,
                 from /usr/lib/gcc/i686-w64-mingw32/6.1-win32/include/xmmintrin.h:34,
                 from /usr/lib/gcc/i686-w64-mingw32/6.1-win32/include/emmintrin.h:31,
                 from ../arch/dotproductsse.cpp:40:
/usr/lib/gcc/i686-w64-mingw32/6.1-win32/include/c++/i686-w64-mingw32/bits/os_defines.h:45:0:
 note: this is the location of the previous definition
 #define NOMINMAX 1

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 16:22:11 +01:00
Zdenko Podobný
f9253c197e Fix build for Mingw-w64 (120a5dbdab) and non C++11 build (VS2010) 2016-12-07 16:21:52 +01:00
Ray Smith
e9be858503 Fixed the memory leak/double free cleanly 2016-12-07 16:04:36 +01:00
Ray Smith
2940b44bcd Missing pdf font file from previous sync 2016-12-07 16:03:05 +01:00
Stefan Weil
743eb8104a Simplify delete operations
It is not necessary to check for null pointers.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 15:59:11 +01:00
Stefan Weil
c73f21aa6f Simplify calls of free
It is not necessary to check for null pointers.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 15:59:01 +01:00
Stefan Weil
892c007685 opencl: Fix OpenCL kernel code assertion for newer versions
With Debian package beignet-opencl-icd 1.2.1-1, Tesseract + OpenCL fails:

[DS] Profile file not available (tesseract_opencl_profile_devices.dat); performing profiling.

[DS] Device: "Intel(R) HD Graphics IvyBridge M GT2" (OpenCL) evaluation...
ASSERTION FAILED: sel.hasDoubleType()
  at file /home/geier/beignet/backend/src/backend/gen_insn_selection.cpp, function void gbe::ConvertInstructionPattern::convertDoubleToSmallInts(gbe::Selection::Opaque&, const gbe::ir::ConvertInstruction&, bool&) const, line 5269
Trace/breakpoint trap

Using a pure float expression (instead of double) fixes this issue.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 15:58:39 +01:00
Stefan Weil
4ade2752fc opencl: Format OpenCL kernel code
* Remove some empty lines to get a more uniform code
* Fix #endif handling at end of file

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 15:58:24 +01:00
Stefan Weil
46a84e761f opencl: Clean whitespace issues in OpenCL kernel code
* Remove whitespace at line endings
* Replace tabs by spaces

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-07 15:58:12 +01:00
Zdenko Podobný
c1d37120a5 backport from 4.00: imagedata 2016-12-07 15:55:27 +01:00
Zdenko Podobný
7099358510 backport from 4.00: training 2016-12-04 22:06:52 +01:00
Zdenko Podobný
53152e4221 change VS2010 lib project name 2016-12-02 21:28:31 +01:00
Zdenko Podobný
9ccda80dd6 backport from 4.00: training shell scripts 2016-12-02 21:07:28 +01:00
Zdenko Podobný
948689bd94 Merge branch '3.05' of https://github.com/tesseract-ocr/tesseract into 3.05 2016-12-02 21:02:55 +01:00
Zdenko Podobný
fc3d07b44f backport from 4.00: api changes 2016-12-02 21:01:17 +01:00
Zdenko Podobný
af1d856cd9 backport from 4.00: code improvements 2016-12-02 20:27:29 +01:00
Zdenko Podobný
2f8c1e7b52 backport from 4.00: split Dict::Load to SetupForLoad, Load and FinishLoad 2016-12-02 20:03:41 +01:00
Zdenko Podobný
775a108dc7 backport from 4.00: enable selection of OCR engine mode from command line 2016-12-02 19:50:54 +01:00
Zdenko Podobný
5750e728d9 use TessHashMap instead of hash_map, unordered_map 2016-11-30 21:58:57 +01:00
Zdenko Podobný
0cbbbe6321 backport from 4.00: SkipDeSerialize and changes in ccutil 2016-11-30 19:52:18 +01:00
Zdenko Podobný
9d1db80c69 backport from 4.00: changes from ccstruct excluding imagedata 2016-11-30 19:29:59 +01:00
Zdenko Podobný
3b777159a4 backport from 4.00: changes in classify 2016-11-30 18:44:55 +01:00
Zdenko Podobný
57d38b9270 backport from 4.00: changes in Android.mk 2016-11-30 12:59:42 +01:00
Zdenko Podobn??
e3236f44ce backport from 4.00: changes in textord 2016-11-30 12:01:58 +01:00
Zdenko Podobn??
ed0c60bc65 backport from 4.00: use ".empty()" instead of ".size() > 0" 2016-11-30 11:33:35 +01:00