Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* '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"
  • Loading branch information
zdenop committed Oct 3, 2018
2 parents bf6d929 + 4237987 commit dcc50a8
Show file tree
Hide file tree
Showing 94 changed files with 2,453 additions and 2,611 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ echo "You can now build and install $PACKAGE_NAME by running:"
echo ""
echo "$ make"
echo "$ sudo make install"
echo "$ sudo ldconfig"
echo ""
AM_COND_IF([ASCIIDOC],
Expand Down
22 changes: 11 additions & 11 deletions src/api/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,9 @@ TESS_API struct Boxa* TESS_CALL TessBaseAPIGetComponentImages(TessBaseAPI* handl
}

TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetComponentImages1( TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids)
TESS_CALL TessBaseAPIGetComponentImages1(TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids)
{
return handle->GetComponentImages(level, text_only != FALSE, raw_image, raw_padding, pixa, blockids, paraids);
}
Expand Down Expand Up @@ -825,37 +825,37 @@ TESS_API ETEXT_DESC* TESS_CALL TessMonitorCreate()
return new ETEXT_DESC();
}

TESS_API void TESS_CALL TessMonitorDelete( ETEXT_DESC* monitor )
TESS_API void TESS_CALL TessMonitorDelete(ETEXT_DESC* monitor)
{
delete monitor;
}

TESS_API void TESS_CALL TessMonitorSetCancelFunc( ETEXT_DESC* monitor, TessCancelFunc cancelFunc )
TESS_API void TESS_CALL TessMonitorSetCancelFunc(ETEXT_DESC* monitor, TessCancelFunc cancelFunc)
{
monitor->cancel = cancelFunc;
}

TESS_API void TESS_CALL TessMonitorSetCancelThis( ETEXT_DESC* monitor, void* cancelThis )
TESS_API void TESS_CALL TessMonitorSetCancelThis(ETEXT_DESC* monitor, void* cancelThis)
{
monitor->cancel_this = cancelThis;
}

TESS_API void* TESS_CALL TessMonitorGetCancelThis( ETEXT_DESC* monitor )
TESS_API void* TESS_CALL TessMonitorGetCancelThis(ETEXT_DESC* monitor)
{
return monitor->cancel_this;
}

TESS_API void TESS_CALL TessMonitorSetProgressFunc( ETEXT_DESC* monitor, TessProgressFunc progressFunc )
TESS_API void TESS_CALL TessMonitorSetProgressFunc(ETEXT_DESC* monitor, TessProgressFunc progressFunc)
{
monitor->progress_callback2 = progressFunc;
}

TESS_API int TESS_CALL TessMonitorGetProgress( ETEXT_DESC* monitor )
TESS_API int TESS_CALL TessMonitorGetProgress(ETEXT_DESC* monitor)
{
return monitor->progress;
}

TESS_API void TESS_CALL TessMonitorSetDeadlineMSecs( ETEXT_DESC* monitor, int deadline )
TESS_API void TESS_CALL TessMonitorSetDeadlineMSecs(ETEXT_DESC* monitor, int deadline)
{
monitor->set_deadline_msecs( deadline );
monitor->set_deadline_msecs(deadline);
}
46 changes: 23 additions & 23 deletions src/api/capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ TESS_API void TESS_CALL TessBaseAPIDelete(TessBaseAPI* handle);

TESS_API size_t TESS_CALL TessBaseAPIGetOpenCLDevice(TessBaseAPI* handle, void **device);

TESS_API void TESS_CALL TessBaseAPISetInputName( TessBaseAPI* handle, const char* name);
TESS_API void TESS_CALL TessBaseAPISetInputName(TessBaseAPI* handle, const char* name);
TESS_API const char* TESS_CALL TessBaseAPIGetInputName(TessBaseAPI* handle);

TESS_API void TESS_CALL TessBaseAPISetInputImage(TessBaseAPI* handle, struct Pix* pix);
Expand All @@ -165,13 +165,13 @@ TESS_API void TESS_CALL TessBaseAPISetOutputName(TessBaseAPI* handle, const cha
TESS_API BOOL TESS_CALL TessBaseAPISetVariable(TessBaseAPI* handle, const char* name, const char* value);
TESS_API BOOL TESS_CALL TessBaseAPISetDebugVariable(TessBaseAPI* handle, const char* name, const char* value);

TESS_API BOOL TESS_CALL TessBaseAPIGetIntVariable( const TessBaseAPI* handle, const char* name, int* value);
TESS_API BOOL TESS_CALL TessBaseAPIGetBoolVariable( const TessBaseAPI* handle, const char* name, BOOL* value);
TESS_API BOOL TESS_CALL TessBaseAPIGetIntVariable(const TessBaseAPI* handle, const char* name, int* value);
TESS_API BOOL TESS_CALL TessBaseAPIGetBoolVariable(const TessBaseAPI* handle, const char* name, BOOL* value);
TESS_API BOOL TESS_CALL TessBaseAPIGetDoubleVariable(const TessBaseAPI* handle, const char* name, double* value);
TESS_API const char*
TESS_CALL TessBaseAPIGetStringVariable(const TessBaseAPI* handle, const char* name);

TESS_API void TESS_CALL TessBaseAPIPrintVariables( const TessBaseAPI* handle, FILE* fp);
TESS_API void TESS_CALL TessBaseAPIPrintVariables(const TessBaseAPI* handle, FILE* fp);
TESS_API BOOL TESS_CALL TessBaseAPIPrintVariablesToFile(const TessBaseAPI* handle, const char* filename);

#ifdef TESS_CAPI_INCLUDE_BASEAPI
Expand Down Expand Up @@ -231,27 +231,27 @@ TESS_API void TESS_CALL TessBaseAPISetThresholder(TessBaseAPI* handle, TessImag
#endif

TESS_API struct Pix*
TESS_CALL TessBaseAPIGetThresholdedImage( TessBaseAPI* handle);
TESS_CALL TessBaseAPIGetThresholdedImage(TessBaseAPI* handle);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetRegions( TessBaseAPI* handle, struct Pixa** pixa);
TESS_CALL TessBaseAPIGetRegions(TessBaseAPI* handle, struct Pixa** pixa);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetTextlines( TessBaseAPI* handle, struct Pixa** pixa, int** blockids);
TESS_CALL TessBaseAPIGetTextlines(TessBaseAPI* handle, struct Pixa** pixa, int** blockids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetTextlines1( TessBaseAPI* handle, const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids);
TESS_CALL TessBaseAPIGetTextlines1(TessBaseAPI* handle, const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetStrips( TessBaseAPI* handle, struct Pixa** pixa, int** blockids);
TESS_CALL TessBaseAPIGetStrips(TessBaseAPI* handle, struct Pixa** pixa, int** blockids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetWords( TessBaseAPI* handle, struct Pixa** pixa);
TESS_CALL TessBaseAPIGetWords(TessBaseAPI* handle, struct Pixa** pixa);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetConnectedComponents(TessBaseAPI* handle, struct Pixa** cc);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetComponentImages( TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
struct Pixa** pixa, int** blockids);
TESS_CALL TessBaseAPIGetComponentImages(TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
struct Pixa** pixa, int** blockids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetComponentImages1( TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids);
TESS_CALL TessBaseAPIGetComponentImages1(TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids);

TESS_API int TESS_CALL TessBaseAPIGetThresholdedImageScaleFactor(const TessBaseAPI* handle);

Expand Down Expand Up @@ -405,13 +405,13 @@ TESS_API float TESS_CALL TessChoiceIteratorConfidence(const TessChoiceIterator*
/* Progress monitor */

TESS_API ETEXT_DESC* TESS_CALL TessMonitorCreate();
TESS_API void TESS_CALL TessMonitorDelete( ETEXT_DESC* monitor );
TESS_API void TESS_CALL TessMonitorSetCancelFunc( ETEXT_DESC* monitor, TessCancelFunc cancelFunc );
TESS_API void TESS_CALL TessMonitorSetCancelThis( ETEXT_DESC* monitor, void* cancelThis );
TESS_API void* TESS_CALL TessMonitorGetCancelThis( ETEXT_DESC* monitor );
TESS_API void TESS_CALL TessMonitorSetProgressFunc( ETEXT_DESC* monitor, TessProgressFunc progressFunc );
TESS_API int TESS_CALL TessMonitorGetProgress( ETEXT_DESC* monitor );
TESS_API void TESS_CALL TessMonitorSetDeadlineMSecs( ETEXT_DESC* monitor, int deadline );
TESS_API void TESS_CALL TessMonitorDelete(ETEXT_DESC* monitor);
TESS_API void TESS_CALL TessMonitorSetCancelFunc(ETEXT_DESC* monitor, TessCancelFunc cancelFunc);
TESS_API void TESS_CALL TessMonitorSetCancelThis(ETEXT_DESC* monitor, void* cancelThis);
TESS_API void* TESS_CALL TessMonitorGetCancelThis(ETEXT_DESC* monitor);
TESS_API void TESS_CALL TessMonitorSetProgressFunc(ETEXT_DESC* monitor, TessProgressFunc progressFunc);
TESS_API int TESS_CALL TessMonitorGetProgress(ETEXT_DESC* monitor);
TESS_API void TESS_CALL TessMonitorSetDeadlineMSecs(ETEXT_DESC* monitor, int deadline);


#ifndef DISABLED_LEGACY_ENGINE
Expand Down
10 changes: 9 additions & 1 deletion src/api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,19 +530,27 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
}

if (FILE* file = fopen(image, "r")) {
fclose(file);
} else {
fprintf(stderr, "Cannot open input file: %s\n", image);
return EXIT_FAILURE;
}

FixPageSegMode(&api, pagesegmode);

if (dpi) {
char dpi_string[255];
snprintf(dpi_string, 254, "%d", dpi);
api.SetVariable("user_defined_dpi", dpi_string);
}

if (pagesegmode == tesseract::PSM_AUTO_ONLY) {
int ret_val = EXIT_SUCCESS;

Pix* pixs = pixRead(image);
if (!pixs) {
fprintf(stderr, "Cannot open input file: %s\n", image);
fprintf(stderr, "Leptonica can't process input file: %s\n", image);
return 2;
}

Expand Down
1 change: 0 additions & 1 deletion src/ccstruct/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ noinst_HEADERS = \
ccstruct.h coutln.h crakedge.h \
debugpixa.h detlinefit.h dppoint.h fontinfo.h \
imagedata.h \
ipoints.h \
linlsq.h matrix.h mod128.h normalis.h \
ocrblock.h ocrpara.h ocrrow.h otsuthr.h \
pageres.h params_training_featdef.h \
Expand Down
2 changes: 1 addition & 1 deletion src/ccstruct/blobbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "environ.h" // for l_uint32
#include "helpers.h" // for UpdateRange, IntCastRounded
#include "host.h" // for NearlyEqual, TRUE
#include "ipoints.h" // for operator+=, ICOORD::rotate
#include "points.h" // for operator+=, ICOORD::rotate

struct Pix;

Expand Down
1 change: 0 additions & 1 deletion src/ccstruct/coutln.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <cstdint> // for int16_t, int32_t
#include "bits16.h" // for BITS16
#include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK
#include "ipoints.h" // for operator+=
#include "mod128.h" // for DIR128, DIRBITS
#include "platform.h" // for DLLSYM
#include "points.h" // for ICOORD, FCOORD
Expand Down
Loading

0 comments on commit dcc50a8

Please sign in to comment.