Skip to content

Commit

Permalink
fix for windows build - part 1
Browse files Browse the repository at this point in the history
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@883 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
[email protected] committed Sep 25, 2013
1 parent 311126d commit af319b4
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 13 deletions.
4 changes: 4 additions & 0 deletions api/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions ccstruct/coutln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions ccstruct/points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*
**********************************************************************/

#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif // _MSC_VER

#include <stdlib.h>
#include "helpers.h"
#include "ndminx.h"
Expand Down
4 changes: 4 additions & 0 deletions ccutil/genericvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,10 @@ int GenericVector<T>::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
Expand Down
4 changes: 4 additions & 0 deletions textord/baselinedetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
//
///////////////////////////////////////////////////////////////////////

#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif // _MSC_VER

#include "baselinedetect.h"

#include <math.h>
Expand Down
12 changes: 8 additions & 4 deletions textord/bbgrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ext/hash_set>
using __gnu_cxx::hash_set;
#else
#include <hash_set>
#ifdef _MSC_VER
using namespace stdext;
#else
using std::hash_set;
#endif
#endif // _MSC_VER
#endif // gcc
#else
#include <hash_set>
#endif
#endif // USE_STD_NAMESPACE
#include "allheaders.h"

class BLOCK;
Expand Down
2 changes: 1 addition & 1 deletion vs2008/port/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
6 changes: 6 additions & 0 deletions wordrec/language_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit af319b4

Please sign in to comment.