diff --git a/api/renderer.cpp b/api/renderer.cpp index b55f846bec..85ff1338d9 100644 --- a/api/renderer.cpp +++ b/api/renderer.cpp @@ -8,6 +8,10 @@ #include "genericvector.h" #include "renderer.h" +#if !defined(VERSION) +#include "version.h" +#endif + namespace tesseract { // Start with a 4K output buffer which should be pretty big for a page of text diff --git a/ccstruct/coutln.cpp b/ccstruct/coutln.cpp index a13238d929..90be0c823d 100644 --- a/ccstruct/coutln.cpp +++ b/ccstruct/coutln.cpp @@ -657,10 +657,10 @@ static void ComputeGradient(const l_uint32* data, int wpl, int x, int y, int width, int height, ICOORD* gradient) { const l_uint32* line = data + y * wpl; - int pix_x_y = x < width && y < height ? GET_DATA_BYTE(line, x) : 255; - int pix_x_prevy = x < width && y > 0 ? GET_DATA_BYTE(line - wpl, x) : 255; - int pix_prevx_prevy = x > 0 && y > 0 ? GET_DATA_BYTE(line - wpl, x - 1) : 255; - int pix_prevx_y = x > 0 && y < height ? GET_DATA_BYTE(line, x - 1) : 255; + int pix_x_y = x < width && y < height ? GET_DATA_BYTE((void *)line, x) : 255; + int pix_x_prevy = x < width && y > 0 ? GET_DATA_BYTE((void *)(line - wpl), x) : 255; + int pix_prevx_prevy = x > 0 && y > 0 ? GET_DATA_BYTE((void *)(line - wpl), x - 1) : 255; + int pix_prevx_y = x > 0 && y < height ? GET_DATA_BYTE((void *)line, x - 1) : 255; gradient->set_x(pix_x_y + pix_x_prevy - (pix_prevx_y + pix_prevx_prevy)); gradient->set_y(pix_x_prevy + pix_prevx_prevy - (pix_x_y + pix_prevx_y)); } @@ -674,8 +674,8 @@ static bool EvaluateVerticalDiff(const l_uint32* data, int wpl, int diff_sign, if (y <= 0 || y >= height) return false; const l_uint32* line = data + y * wpl; - int pixel1 = GET_DATA_BYTE(line - wpl, x); - int pixel2 = GET_DATA_BYTE(line, x); + int pixel1 = GET_DATA_BYTE((void *)(line - wpl), x); + int pixel2 = GET_DATA_BYTE((void *)line, x); int diff = (pixel2 - pixel1) * diff_sign; if (diff > *best_diff) { *best_diff = diff; @@ -693,8 +693,8 @@ static bool EvaluateHorizontalDiff(const l_uint32* line, int diff_sign, int* best_diff, int* best_sum, int* best_x) { if (x <= 0 || x >= width) return false; - int pixel1 = GET_DATA_BYTE(line, x - 1); - int pixel2 = GET_DATA_BYTE(line, x); + int pixel1 = GET_DATA_BYTE((void *)line, x - 1); + int pixel2 = GET_DATA_BYTE((void *)line, x); int diff = (pixel2 - pixel1) * diff_sign; if (diff > *best_diff) { *best_diff = diff; diff --git a/ccstruct/points.cpp b/ccstruct/points.cpp index c0a9922f11..6569fba417 100644 --- a/ccstruct/points.cpp +++ b/ccstruct/points.cpp @@ -17,6 +17,10 @@ * **********************************************************************/ +#ifdef _MSC_VER +#define _USE_MATH_DEFINES +#endif // _MSC_VER + #include #include "helpers.h" #include "ndminx.h" diff --git a/ccutil/genericvector.h b/ccutil/genericvector.h index c1b2f059b1..3122549564 100644 --- a/ccutil/genericvector.h +++ b/ccutil/genericvector.h @@ -877,6 +877,10 @@ int GenericVector::choose_nth_item(int target_index, int start, int end, } } // Place the pivot at start. + #ifdef _MSC_VER // TODO(zdenop): check this + srand( (unsigned) seed ); + #define rand_r(seed) rand() + #endif // _MSC_VER int pivot = rand_r(seed) % num_elements + start; swap(pivot, start); // The invariant condition here is that items [start, next_lesser) are less diff --git a/textord/baselinedetect.cpp b/textord/baselinedetect.cpp index b5feb5e45b..4c9e977798 100644 --- a/textord/baselinedetect.cpp +++ b/textord/baselinedetect.cpp @@ -17,6 +17,10 @@ // /////////////////////////////////////////////////////////////////////// +#ifdef _MSC_VER +#define _USE_MATH_DEFINES +#endif // _MSC_VER + #include "baselinedetect.h" #include diff --git a/textord/bbgrid.h b/textord/bbgrid.h index d2e7710988..8b81ebb74d 100644 --- a/textord/bbgrid.h +++ b/textord/bbgrid.h @@ -30,19 +30,23 @@ // you don't get this functionality. #ifdef HAVE_CONFIG_H #include "config_auto.h" -#endif +#endif // HAVE_CONFIG_H #ifdef USE_STD_NAMESPACE -#ifdef __linux__ +#if (defined(__GNUC__) && (((__GNUC__ == 3) && ( __GNUC_MINOR__ > 0)) || __GNUC__ >= 4)) // gcc // hash_set is deprecated in gcc #include using __gnu_cxx::hash_set; #else #include +#ifdef _MSC_VER +using namespace stdext; +#else using std::hash_set; -#endif +#endif // _MSC_VER +#endif // gcc #else #include -#endif +#endif // USE_STD_NAMESPACE #include "allheaders.h" class BLOCK; diff --git a/vs2008/port/version.h b/vs2008/port/version.h index 52e9b78bdb..b1bdf4ceb0 100644 --- a/vs2008/port/version.h +++ b/vs2008/port/version.h @@ -20,6 +20,6 @@ #ifndef VS2008_PORT_VERSION_H_ #define VS2008_PORT_VERSION_H_ -#define VERSION "3.02.03" +#define VERSION "3.03" #endif // VS2008_PORT_VERSION_H_ diff --git a/wordrec/language_model.cpp b/wordrec/language_model.cpp index 83f7e64710..2f430a0e55 100644 --- a/wordrec/language_model.cpp +++ b/wordrec/language_model.cpp @@ -32,6 +32,12 @@ #include "params.h" #include "params_training_featdef.h" +#ifdef _MSC_VER +double log2(double n) { + return log(n) / log(double(2)); +} +#endif // _MSC_VER + namespace tesseract { const float LanguageModel::kMaxAvgNgramCost = 25.0f;