mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-06-07 18:02:40 +08:00
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccmain: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccstruct: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * classify: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * cutil: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * dict: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * textord: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * training: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * wordrec: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccutil: Replace Tesseract data types by POSIX data types Now all Tesseract data types which are no longer needed can be removed from ccutil/host.h. Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Remove the macros which are now unused from ccutil/host.h. Remove also the obsolete history comments. Signed-off-by: Stefan Weil <sw@weilnetz.de> * Fix build error caused by ambiguous ClipToRange Error message vom Appveyor CI: C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj] C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj] c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange' C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char' C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int' Signed-off-by: Stefan Weil <sw@weilnetz.de> * unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
40c71bfcb8
commit
023e1b340e
@ -285,7 +285,7 @@ bool TessBaseAPI::GetIntVariable(const char *name, int *value) const {
|
||||
IntParam *p = ParamUtils::FindParam<IntParam>(
|
||||
name, GlobalParams()->int_params, tesseract_->params()->int_params);
|
||||
if (p == NULL) return false;
|
||||
*value = (inT32)(*p);
|
||||
*value = (int32_t)(*p);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1697,7 +1697,7 @@ char* TessBaseAPI::GetTSVText(int page_number) {
|
||||
/** The 5 numbers output for each box (the usual 4 and a page number.) */
|
||||
const int kNumbersPerBlob = 5;
|
||||
/**
|
||||
* The number of bytes taken by each number. Since we use inT16 for ICOORD,
|
||||
* The number of bytes taken by each number. Since we use int16_t for ICOORD,
|
||||
* assume only 5 digits max.
|
||||
*/
|
||||
const int kBytesPerNumber = 5;
|
||||
@ -1707,7 +1707,7 @@ const int kBytesPerNumber = 5;
|
||||
* original UTF8 characters, and one kMaxBytesPerLine for safety.
|
||||
*/
|
||||
const int kBytesPerBoxFileLine = (kBytesPerNumber + 1) * kNumbersPerBlob + 1;
|
||||
/** Max bytes in the decimal representation of inT64. */
|
||||
/** Max bytes in the decimal representation of int64_t. */
|
||||
const int kBytesPer64BitNumber = 20;
|
||||
/**
|
||||
* A maximal single box could occupy kNumbersPerBlob numbers at
|
||||
@ -2479,7 +2479,7 @@ ROW *TessBaseAPI::MakeTessOCRRow(float baseline,
|
||||
float xheight,
|
||||
float descender,
|
||||
float ascender) {
|
||||
inT32 xstarts[] = {-32000};
|
||||
int32_t xstarts[] = {-32000};
|
||||
double quad_coeffs[] = {0, 0, baseline};
|
||||
return new ROW(1,
|
||||
xstarts,
|
||||
|
@ -103,7 +103,7 @@ void IntSimdMatrix::MatrixDotVector(const GENERIC_2D_ARRAY<int8_t>& w,
|
||||
int total = 0;
|
||||
for (int j = 0; j < num_in; ++j) total += wi[j] * u[j];
|
||||
// Add in the bias and correct for integer values.
|
||||
v[i] = (static_cast<double>(total) / MAX_INT8 + wi[num_in]) * scales[i];
|
||||
v[i] = (static_cast<double>(total) / INT8_MAX + wi[num_in]) * scales[i];
|
||||
}
|
||||
} else {
|
||||
const int8_t* w_data = shaped_w_.data();
|
||||
|
@ -84,7 +84,7 @@ inline void ExtractResults(__m256i& result, __m256i& shift_id,
|
||||
((int32_t*)&result)[0]
|
||||
#endif
|
||||
;
|
||||
*v++ = (static_cast<double>(res) / MAX_INT8 + *wi++) * *scales++;
|
||||
*v++ = (static_cast<double>(res) / INT8_MAX + *wi++) * *scales++;
|
||||
// Rotate the results in int32_t units, so the next result is ready.
|
||||
result = _mm256_permutevar8x32_epi32(result, shift_id);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ static void PartialMatrixDotVector1(const int8_t* wi, const double* scales,
|
||||
double* v) {
|
||||
int total = IntDotProductSSE(u, wi, num_in);
|
||||
// Add in the bias and correct for integer values.
|
||||
*v = (static_cast<double>(total) / MAX_INT8 + wi[num_in]) * *scales;
|
||||
*v = (static_cast<double>(total) / INT8_MAX + wi[num_in]) * *scales;
|
||||
}
|
||||
#endif // __SSE4_1__
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
namespace tesseract {
|
||||
BOOL8 Tesseract::word_adaptable( //should we adapt?
|
||||
WERD_RES *word,
|
||||
uinT16 mode) {
|
||||
uint16_t mode) {
|
||||
if (tessedit_adaption_debug) {
|
||||
tprintf("Running word_adaptable() for %s rating %.4f certainty %.4f\n",
|
||||
word->best_choice == NULL ? "" :
|
||||
|
@ -268,11 +268,11 @@ void Tesseract::MaximallyChopWord(const GenericVector<TBOX>& boxes,
|
||||
}
|
||||
GenericVector<BLOB_CHOICE*> blob_choices;
|
||||
ASSERT_HOST(!word_res->chopped_word->blobs.empty());
|
||||
float rating = static_cast<float>(MAX_INT8);
|
||||
float rating = static_cast<float>(INT8_MAX);
|
||||
for (int i = 0; i < word_res->chopped_word->NumBlobs(); ++i) {
|
||||
// The rating and certainty are not quite arbitrary. Since
|
||||
// select_blob_to_chop uses the worst certainty to choose, they all have
|
||||
// to be different, so starting with MAX_INT8, subtract 1/8 for each blob
|
||||
// to be different, so starting with INT8_MAX, subtract 1/8 for each blob
|
||||
// in here, and then divide by e each time they are chopped, which
|
||||
// should guarantee a set of unequal values for the whole tree of blobs
|
||||
// produced, however much chopping is required. The chops are thus only
|
||||
|
@ -80,8 +80,8 @@ void Tesseract::recog_pseudo_word(PAGE_RES* page_res,
|
||||
* @param pr_it the page results iterator
|
||||
*/
|
||||
BOOL8 Tesseract::recog_interactive(PAGE_RES_IT* pr_it) {
|
||||
inT16 char_qual;
|
||||
inT16 good_char_qual;
|
||||
int16_t char_qual;
|
||||
int16_t good_char_qual;
|
||||
|
||||
WordData word_data(*pr_it);
|
||||
SetupWordPassN(2, &word_data);
|
||||
@ -636,8 +636,8 @@ void Tesseract::rejection_passes(PAGE_RES* page_res,
|
||||
stats_.doc_blob_quality += blob_quality;
|
||||
int outline_errs = word_outline_errs(word);
|
||||
stats_.doc_outline_errs += outline_errs;
|
||||
inT16 all_char_quality;
|
||||
inT16 accepted_all_char_quality;
|
||||
int16_t all_char_quality;
|
||||
int16_t accepted_all_char_quality;
|
||||
word_char_quality(word, page_res_it.row()->row,
|
||||
&all_char_quality, &accepted_all_char_quality);
|
||||
stats_.doc_char_quality += all_char_quality;
|
||||
@ -757,8 +757,8 @@ void Tesseract::script_pos_pass(PAGE_RES* page_res) {
|
||||
// Helper finds the gap between the index word and the next.
|
||||
static void WordGap(const PointerVector<WERD_RES>& words, int index, int* right,
|
||||
int* next_left) {
|
||||
*right = -MAX_INT32;
|
||||
*next_left = MAX_INT32;
|
||||
*right = -INT32_MAX;
|
||||
*next_left = INT32_MAX;
|
||||
if (index < words.size()) {
|
||||
*right = words[index]->word->bounding_box().right();
|
||||
if (index + 1 < words.size())
|
||||
@ -812,11 +812,11 @@ static int SelectBestWords(double rating_ratio,
|
||||
// Start of the current run in each.
|
||||
int start_b = b, start_n = n;
|
||||
while (b < best_words->size() || n < new_words->size()) {
|
||||
int b_right = -MAX_INT32;
|
||||
int next_b_left = MAX_INT32;
|
||||
int b_right = -INT32_MAX;
|
||||
int next_b_left = INT32_MAX;
|
||||
WordGap(*best_words, b, &b_right, &next_b_left);
|
||||
int n_right = -MAX_INT32;
|
||||
int next_n_left = MAX_INT32;
|
||||
int n_right = -INT32_MAX;
|
||||
int next_n_left = INT32_MAX;
|
||||
WordGap(*new_words, n, &n_right, &next_n_left);
|
||||
if (MAX(b_right, n_right) < MIN(next_b_left, next_n_left)) {
|
||||
// The word breaks overlap. [start_b,b] and [start_n, n] match.
|
||||
@ -1793,7 +1793,7 @@ ACCEPTABLE_WERD_TYPE Tesseract::acceptable_word_string(
|
||||
|
||||
BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
|
||||
BOOL8 show_map_detail = FALSE;
|
||||
inT16 i;
|
||||
int16_t i;
|
||||
|
||||
if (!test_pt)
|
||||
return FALSE;
|
||||
@ -1880,17 +1880,17 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
|
||||
*/
|
||||
static void find_modal_font( // good chars in word
|
||||
STATS* fonts, // font stats
|
||||
inT16* font_out, // output font
|
||||
int16_t* font_out, // output font
|
||||
int8_t* font_count // output count
|
||||
) {
|
||||
inT16 font; //font index
|
||||
inT32 count; //pile couat
|
||||
int16_t font; //font index
|
||||
int32_t count; //pile count
|
||||
|
||||
if (fonts->get_total () > 0) {
|
||||
font = (inT16) fonts->mode ();
|
||||
font = (int16_t) fonts->mode ();
|
||||
*font_out = font;
|
||||
count = fonts->pile_count (font);
|
||||
*font_count = count < MAX_INT8 ? count : MAX_INT8;
|
||||
*font_count = count < INT8_MAX ? count : INT8_MAX;
|
||||
fonts->add (font, -*font_count);
|
||||
}
|
||||
else {
|
||||
@ -1935,7 +1935,7 @@ void Tesseract::set_word_fonts(WERD_RES *word) {
|
||||
}
|
||||
// Find the top and 2nd choice for the word.
|
||||
int score1 = 0, score2 = 0;
|
||||
inT16 font_id1 = -1, font_id2 = -1;
|
||||
int16_t font_id1 = -1, font_id2 = -1;
|
||||
for (int f = 0; f < fontinfo_size; ++f) {
|
||||
if (tessedit_debug_fonts && font_total_score[f] > 0) {
|
||||
tprintf("Font %s, total score = %d\n",
|
||||
@ -1953,10 +1953,10 @@ void Tesseract::set_word_fonts(WERD_RES *word) {
|
||||
}
|
||||
word->fontinfo = font_id1 >= 0 ? &fontinfo_table_.get(font_id1) : NULL;
|
||||
word->fontinfo2 = font_id2 >= 0 ? &fontinfo_table_.get(font_id2) : NULL;
|
||||
// Each score has a limit of MAX_UINT16, so divide by that to get the number
|
||||
// Each score has a limit of UINT16_MAX, so divide by that to get the number
|
||||
// of "votes" for that font, ie number of perfect scores.
|
||||
word->fontinfo_id_count = ClipToRange(score1 / MAX_UINT16, 1, MAX_INT8);
|
||||
word->fontinfo_id2_count = ClipToRange(score2 / MAX_UINT16, 0, MAX_INT8);
|
||||
word->fontinfo_id_count = ClipToRange<int>(score1 / UINT16_MAX, 1, INT8_MAX);
|
||||
word->fontinfo_id2_count = ClipToRange<int>(score2 / UINT16_MAX, 0, INT8_MAX);
|
||||
if (score1 > 0) {
|
||||
FontInfo fi = fontinfo_table_.get(font_id1);
|
||||
if (tessedit_debug_fonts) {
|
||||
@ -1998,7 +1998,7 @@ void Tesseract::font_recognition_pass(PAGE_RES* page_res) {
|
||||
doc_fonts.add(word->fontinfo2->universal_id, word->fontinfo_id2_count);
|
||||
}
|
||||
}
|
||||
inT16 doc_font; // modal font
|
||||
int16_t doc_font; // modal font
|
||||
int8_t doc_font_count; // modal font
|
||||
find_modal_font(&doc_fonts, &doc_font, &doc_font_count);
|
||||
if (doc_font_count == 0)
|
||||
|
@ -52,8 +52,8 @@ struct DocQualCallbacks {
|
||||
}
|
||||
|
||||
WERD_RES* word;
|
||||
inT16 match_count;
|
||||
inT16 accepted_match_count;
|
||||
int16_t match_count;
|
||||
int16_t accepted_match_count;
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
@ -62,7 +62,7 @@ struct DocQualCallbacks {
|
||||
* ASSUME blobs in both initial word and box_word are in ascending order of
|
||||
* left hand blob edge.
|
||||
*************************************************************************/
|
||||
inT16 Tesseract::word_blob_quality(WERD_RES *word, ROW *row) {
|
||||
int16_t Tesseract::word_blob_quality(WERD_RES *word, ROW *row) {
|
||||
if (word->bln_boxes == NULL ||
|
||||
word->rebuild_word == NULL || word->rebuild_word->blobs.empty())
|
||||
return 0;
|
||||
@ -74,9 +74,9 @@ inT16 Tesseract::word_blob_quality(WERD_RES *word, ROW *row) {
|
||||
return cb.match_count;
|
||||
}
|
||||
|
||||
inT16 Tesseract::word_outline_errs(WERD_RES *word) {
|
||||
inT16 i = 0;
|
||||
inT16 err_count = 0;
|
||||
int16_t Tesseract::word_outline_errs(WERD_RES *word) {
|
||||
int16_t i = 0;
|
||||
int16_t err_count = 0;
|
||||
|
||||
if (word->rebuild_word != NULL) {
|
||||
for (int b = 0; b < word->rebuild_word->NumBlobs(); ++b) {
|
||||
@ -96,8 +96,8 @@ inT16 Tesseract::word_outline_errs(WERD_RES *word) {
|
||||
*************************************************************************/
|
||||
void Tesseract::word_char_quality(WERD_RES *word,
|
||||
ROW *row,
|
||||
inT16 *match_count,
|
||||
inT16 *accepted_match_count) {
|
||||
int16_t *match_count,
|
||||
int16_t *accepted_match_count) {
|
||||
if (word->bln_boxes == NULL || word->rebuild_word == NULL ||
|
||||
word->rebuild_word->blobs.empty()) {
|
||||
*match_count = 0;
|
||||
@ -128,7 +128,7 @@ void Tesseract::unrej_good_chs(WERD_RES *word, ROW *row) {
|
||||
NewPermanentTessCallback(&cb, &DocQualCallbacks::AcceptIfGoodQuality));
|
||||
}
|
||||
|
||||
inT16 Tesseract::count_outline_errs(char c, inT16 outline_count) {
|
||||
int16_t Tesseract::count_outline_errs(char c, int16_t outline_count) {
|
||||
int expected_outline_count;
|
||||
|
||||
if (STRING (outlines_odd).contains (c))
|
||||
@ -237,15 +237,15 @@ void Tesseract::unrej_good_quality_words( //unreject potential
|
||||
void Tesseract::doc_and_block_rejection( //reject big chunks
|
||||
PAGE_RES_IT &page_res_it,
|
||||
BOOL8 good_quality_doc) {
|
||||
inT16 block_no = 0;
|
||||
inT16 row_no = 0;
|
||||
int16_t block_no = 0;
|
||||
int16_t row_no = 0;
|
||||
BLOCK_RES *current_block;
|
||||
ROW_RES *current_row;
|
||||
|
||||
BOOL8 rej_word;
|
||||
BOOL8 prev_word_rejected;
|
||||
inT16 char_quality = 0;
|
||||
inT16 accepted_char_quality;
|
||||
int16_t char_quality = 0;
|
||||
int16_t accepted_char_quality;
|
||||
|
||||
if (page_res_it.page_res->rej_count * 100.0 /
|
||||
page_res_it.page_res->char_count > tessedit_reject_doc_percent) {
|
||||
@ -596,9 +596,9 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) {
|
||||
PAGE_RES_IT copy_it;
|
||||
BOOL8 deleting_from_bol = FALSE;
|
||||
BOOL8 marked_delete_point = FALSE;
|
||||
inT16 debug_delete_mode;
|
||||
int16_t debug_delete_mode;
|
||||
CRUNCH_MODE delete_mode;
|
||||
inT16 x_debug_delete_mode;
|
||||
int16_t x_debug_delete_mode;
|
||||
CRUNCH_MODE x_delete_mode;
|
||||
|
||||
page_res_it.restart_page();
|
||||
@ -896,7 +896,7 @@ GARBAGE_LEVEL Tesseract::garbage_word(WERD_RES *word, BOOL8 ok_dict_word) {
|
||||
* >75% of the outline BBs have longest dimension < 0.5xht
|
||||
*************************************************************************/
|
||||
|
||||
CRUNCH_MODE Tesseract::word_deletable(WERD_RES *word, inT16 &delete_mode) {
|
||||
CRUNCH_MODE Tesseract::word_deletable(WERD_RES *word, int16_t &delete_mode) {
|
||||
int word_len = word->reject_map.length ();
|
||||
float rating_per_ch;
|
||||
TBOX box; //BB of word
|
||||
@ -967,7 +967,7 @@ CRUNCH_MODE Tesseract::word_deletable(WERD_RES *word, inT16 &delete_mode) {
|
||||
return CR_NONE;
|
||||
}
|
||||
|
||||
inT16 Tesseract::failure_count(WERD_RES *word) {
|
||||
int16_t Tesseract::failure_count(WERD_RES *word) {
|
||||
const char *str = word->best_choice->unichar_string().string();
|
||||
int tess_rejs = 0;
|
||||
|
||||
@ -981,9 +981,9 @@ inT16 Tesseract::failure_count(WERD_RES *word) {
|
||||
|
||||
BOOL8 Tesseract::noise_outlines(TWERD *word) {
|
||||
TBOX box; // BB of outline
|
||||
inT16 outline_count = 0;
|
||||
inT16 small_outline_count = 0;
|
||||
inT16 max_dimension;
|
||||
int16_t outline_count = 0;
|
||||
int16_t small_outline_count = 0;
|
||||
int16_t max_dimension;
|
||||
float small_limit = kBlnXHeight * crunch_small_outlines_size;
|
||||
|
||||
for (int b = 0; b < word->NumBlobs(); ++b) {
|
||||
|
@ -30,6 +30,6 @@ enum GARBAGE_LEVEL
|
||||
G_TERRIBLE
|
||||
};
|
||||
|
||||
inT16 word_blob_quality(WERD_RES *word, ROW *row);
|
||||
int16_t word_blob_quality(WERD_RES *word, ROW *row);
|
||||
void reject_whole_page(PAGE_RES_IT &page_res_it);
|
||||
#endif
|
||||
|
@ -664,12 +664,12 @@ void EquationDetect::SplitCPHor(ColPartition* part,
|
||||
// the previous blob may have a "more right" right side.
|
||||
// Account for this by always keeping the largest "right"
|
||||
// so far.
|
||||
int previous_right = MIN_INT32;
|
||||
int previous_right = INT32_MIN;
|
||||
|
||||
// Look for the next split in the partition.
|
||||
for (box_it.mark_cycle_pt(); !box_it.cycled_list(); box_it.forward()) {
|
||||
const TBOX& box = box_it.data()->bounding_box();
|
||||
if (previous_right != MIN_INT32 &&
|
||||
if (previous_right != INT32_MIN &&
|
||||
box.left() - previous_right > kThreshold) {
|
||||
// We have a split position. Split the partition in two pieces.
|
||||
// Insert the left piece in the grid and keep processing the right.
|
||||
@ -708,17 +708,17 @@ void EquationDetect::SplitCPHorLite(ColPartition* part,
|
||||
// Account for this by always keeping the largest "right"
|
||||
// so far.
|
||||
TBOX union_box;
|
||||
int previous_right = MIN_INT32;
|
||||
int previous_right = INT32_MIN;
|
||||
BLOBNBOX_C_IT box_it(part->boxes());
|
||||
for (box_it.mark_cycle_pt(); !box_it.cycled_list(); box_it.forward()) {
|
||||
const TBOX& box = box_it.data()->bounding_box();
|
||||
if (previous_right != MIN_INT32 &&
|
||||
if (previous_right != INT32_MIN &&
|
||||
box.left() - previous_right > kThreshold) {
|
||||
// We have a split position.
|
||||
splitted_boxes->push_back(union_box);
|
||||
previous_right = MIN_INT32;
|
||||
previous_right = INT32_MIN;
|
||||
}
|
||||
if (previous_right == MIN_INT32) {
|
||||
if (previous_right == INT32_MIN) {
|
||||
union_box = box;
|
||||
} else {
|
||||
union_box += box;
|
||||
@ -728,7 +728,7 @@ void EquationDetect::SplitCPHorLite(ColPartition* part,
|
||||
}
|
||||
|
||||
// Add the last piece.
|
||||
if (previous_right != MIN_INT32) {
|
||||
if (previous_right != INT32_MIN) {
|
||||
splitted_boxes->push_back(union_box);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace tesseract {
|
||||
* @param[out] page_res
|
||||
*/
|
||||
void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor,
|
||||
inT32 word_count,
|
||||
int32_t word_count,
|
||||
PAGE_RES *page_res) {
|
||||
BLOCK_RES_IT block_res_it;
|
||||
ROW_RES_IT row_res_it;
|
||||
@ -54,9 +54,9 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor,
|
||||
WERD_RES_IT word_res_it_to;
|
||||
WERD_RES *word_res;
|
||||
WERD_RES_LIST fuzzy_space_words;
|
||||
inT16 new_length;
|
||||
int16_t new_length;
|
||||
BOOL8 prevent_null_wd_fixsp; // DON'T process blobless wds
|
||||
inT32 word_index; // current word
|
||||
int32_t word_index; // current word
|
||||
|
||||
block_res_it.set_to_list(&page_res->block_res_list);
|
||||
word_index = 0;
|
||||
@ -145,9 +145,9 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor,
|
||||
void Tesseract::fix_fuzzy_space_list(WERD_RES_LIST &best_perm,
|
||||
ROW *row,
|
||||
BLOCK* block) {
|
||||
inT16 best_score;
|
||||
int16_t best_score;
|
||||
WERD_RES_LIST current_perm;
|
||||
inT16 current_score;
|
||||
int16_t current_score;
|
||||
BOOL8 improved = FALSE;
|
||||
|
||||
best_score = eval_word_spacing(best_perm); // default score
|
||||
@ -236,16 +236,16 @@ void Tesseract::match_current_words(WERD_RES_LIST &words, ROW *row,
|
||||
* confirmed. The only score is from the joined 1. "PS7a713/7a" scores 2.
|
||||
*
|
||||
*/
|
||||
inT16 Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) {
|
||||
int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) {
|
||||
WERD_RES_IT word_res_it(&word_res_list);
|
||||
inT16 total_score = 0;
|
||||
inT16 word_count = 0;
|
||||
inT16 done_word_count = 0;
|
||||
inT16 word_len;
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
int16_t total_score = 0;
|
||||
int16_t word_count = 0;
|
||||
int16_t done_word_count = 0;
|
||||
int16_t word_len;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
WERD_RES *word; // current word
|
||||
inT16 prev_word_score = 0;
|
||||
int16_t prev_word_score = 0;
|
||||
BOOL8 prev_word_done = FALSE;
|
||||
BOOL8 prev_char_1 = FALSE; // prev ch a "1/I/l"?
|
||||
BOOL8 prev_char_digit = FALSE; // prev ch 2..9 or 0
|
||||
@ -376,16 +376,16 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
|
||||
WERD_RES *prev_word;
|
||||
WERD_RES *combo;
|
||||
WERD *copy_word;
|
||||
inT16 prev_right = -MAX_INT16;
|
||||
int16_t prev_right = -INT16_MAX;
|
||||
TBOX box;
|
||||
inT16 gap;
|
||||
inT16 min_gap = MAX_INT16;
|
||||
int16_t gap;
|
||||
int16_t min_gap = INT16_MAX;
|
||||
|
||||
for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
|
||||
word = word_it.data();
|
||||
if (!word->part_of_combo) {
|
||||
box = word->word->bounding_box();
|
||||
if (prev_right > -MAX_INT16) {
|
||||
if (prev_right > -INT16_MAX) {
|
||||
gap = box.left() - prev_right;
|
||||
if (gap < min_gap)
|
||||
min_gap = gap;
|
||||
@ -393,16 +393,16 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
|
||||
prev_right = box.right();
|
||||
}
|
||||
}
|
||||
if (min_gap < MAX_INT16) {
|
||||
prev_right = -MAX_INT16; // back to start
|
||||
if (min_gap < INT16_MAX) {
|
||||
prev_right = -INT16_MAX; // back to start
|
||||
word_it.set_to_list(&words);
|
||||
// Note: we can't use cycle_pt due to inserted combos at start of list.
|
||||
for (; (prev_right == -MAX_INT16) || !word_it.at_first();
|
||||
for (; (prev_right == -INT16_MAX) || !word_it.at_first();
|
||||
word_it.forward()) {
|
||||
word = word_it.data();
|
||||
if (!word->part_of_combo) {
|
||||
box = word->word->bounding_box();
|
||||
if (prev_right > -MAX_INT16) {
|
||||
if (prev_right > -INT16_MAX) {
|
||||
gap = box.left() - prev_right;
|
||||
if (gap <= min_gap) {
|
||||
prev_word = prev_word_it.data();
|
||||
@ -446,8 +446,8 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
|
||||
}
|
||||
|
||||
namespace tesseract {
|
||||
void Tesseract::dump_words(WERD_RES_LIST &perm, inT16 score,
|
||||
inT16 mode, BOOL8 improved) {
|
||||
void Tesseract::dump_words(WERD_RES_LIST &perm, int16_t score,
|
||||
int16_t mode, BOOL8 improved) {
|
||||
WERD_RES_IT word_res_it(&perm);
|
||||
|
||||
if (debug_fix_space_level > 0) {
|
||||
@ -537,8 +537,8 @@ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row,
|
||||
WERD_RES *word_res;
|
||||
WERD_RES_LIST sub_word_list;
|
||||
WERD_RES_IT sub_word_list_it(&sub_word_list);
|
||||
inT16 blob_index;
|
||||
inT16 new_length;
|
||||
int16_t blob_index;
|
||||
int16_t new_length;
|
||||
float junk;
|
||||
|
||||
word_res = word_res_it.data();
|
||||
@ -568,12 +568,12 @@ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row,
|
||||
|
||||
void Tesseract::fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row,
|
||||
BLOCK* block) {
|
||||
inT16 best_score;
|
||||
int16_t best_score;
|
||||
WERD_RES_IT best_perm_it(&best_perm);
|
||||
WERD_RES_LIST current_perm;
|
||||
WERD_RES_IT current_perm_it(¤t_perm);
|
||||
WERD_RES *old_word_res;
|
||||
inT16 current_score;
|
||||
int16_t current_score;
|
||||
BOOL8 improved = FALSE;
|
||||
|
||||
best_score = fp_eval_word_spacing(best_perm); // default score
|
||||
@ -626,8 +626,8 @@ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) {
|
||||
C_BLOB_IT new_blob_it;
|
||||
C_BLOB_IT new_rej_cblob_it;
|
||||
WERD *new_word;
|
||||
inT16 start_of_noise_blob;
|
||||
inT16 i;
|
||||
int16_t start_of_noise_blob;
|
||||
int16_t i;
|
||||
|
||||
for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
|
||||
blob_index = worst_noise_blob(word_it.data(), &noise_score);
|
||||
@ -677,7 +677,7 @@ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) {
|
||||
word_res->ClearResults();
|
||||
}
|
||||
|
||||
inT16 Tesseract::worst_noise_blob(WERD_RES *word_res,
|
||||
int16_t Tesseract::worst_noise_blob(WERD_RES *word_res,
|
||||
float *worst_noise_score) {
|
||||
float noise_score[512];
|
||||
int i;
|
||||
@ -759,9 +759,9 @@ inT16 Tesseract::worst_noise_blob(WERD_RES *word_res,
|
||||
|
||||
float Tesseract::blob_noise_score(TBLOB *blob) {
|
||||
TBOX box; // BB of outline
|
||||
inT16 outline_count = 0;
|
||||
inT16 max_dimension;
|
||||
inT16 largest_outline_dimension = 0;
|
||||
int16_t outline_count = 0;
|
||||
int16_t max_dimension;
|
||||
int16_t largest_outline_dimension = 0;
|
||||
|
||||
for (TESSLINE* ol = blob->outlines; ol != NULL; ol= ol->next) {
|
||||
outline_count++;
|
||||
@ -795,7 +795,7 @@ float Tesseract::blob_noise_score(TBLOB *blob) {
|
||||
void fixspace_dbg(WERD_RES *word) {
|
||||
TBOX box = word->word->bounding_box();
|
||||
BOOL8 show_map_detail = FALSE;
|
||||
inT16 i;
|
||||
int16_t i;
|
||||
|
||||
box.print();
|
||||
tprintf(" \"%s\" ", word->best_choice->unichar_string().string());
|
||||
@ -827,11 +827,11 @@ void fixspace_dbg(WERD_RES *word) {
|
||||
* Penalise any potential noise chars
|
||||
*/
|
||||
namespace tesseract {
|
||||
inT16 Tesseract::fp_eval_word_spacing(WERD_RES_LIST &word_res_list) {
|
||||
int16_t Tesseract::fp_eval_word_spacing(WERD_RES_LIST &word_res_list) {
|
||||
WERD_RES_IT word_it(&word_res_list);
|
||||
WERD_RES *word;
|
||||
inT16 score = 0;
|
||||
inT16 i;
|
||||
int16_t score = 0;
|
||||
int16_t i;
|
||||
float small_limit = kBlnXHeight * fixsp_small_outlines_size;
|
||||
|
||||
for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
|
||||
|
@ -100,8 +100,8 @@ int Tesseract::CountMisfitTops(WERD_RES *word_res) {
|
||||
// See comment above for overall algorithm.
|
||||
float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res,
|
||||
float* baseline_shift) {
|
||||
STATS top_stats(0, MAX_UINT8);
|
||||
STATS shift_stats(-MAX_UINT8, MAX_UINT8);
|
||||
STATS top_stats(0, UINT8_MAX);
|
||||
STATS shift_stats(-UINT8_MAX, UINT8_MAX);
|
||||
int bottom_shift = 0;
|
||||
int num_blobs = word_res->rebuild_word->NumBlobs();
|
||||
do {
|
||||
|
@ -54,14 +54,14 @@
|
||||
* number of points.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 pixels_to_pts( //convert coords
|
||||
inT32 pixels,
|
||||
inT32 pix_res //resolution
|
||||
int32_t pixels_to_pts( //convert coords
|
||||
int32_t pixels,
|
||||
int32_t pix_res //resolution
|
||||
) {
|
||||
float pts; //converted value
|
||||
|
||||
pts = pixels * 72.0 / pix_res;
|
||||
return (inT32) (pts + 0.5); //round it
|
||||
return (int32_t) (pts + 0.5); //round it
|
||||
}
|
||||
|
||||
namespace tesseract {
|
||||
@ -248,8 +248,8 @@ char determine_newline_type( //test line ends
|
||||
WERD *next_word, //next word
|
||||
BLOCK *next_block //block of next word
|
||||
) {
|
||||
inT16 end_gap; //to right edge
|
||||
inT16 width; //of next word
|
||||
int16_t end_gap; //to right edge
|
||||
int16_t width; //of next word
|
||||
TBOX word_box; //bounding
|
||||
TBOX next_box; //next word
|
||||
TBOX block_box; //block bounding
|
||||
@ -265,7 +265,7 @@ char determine_newline_type( //test line ends
|
||||
block_box = block->bounding_box ();
|
||||
//gap to eol
|
||||
end_gap = block_box.right () - word_box.right ();
|
||||
end_gap -= (inT32) block->space ();
|
||||
end_gap -= (int32_t) block->space ();
|
||||
width = next_box.right () - next_box.left ();
|
||||
// tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n",
|
||||
// block_box.right(),word_box.right(),end_gap,
|
||||
@ -395,7 +395,7 @@ void Tesseract::set_unlv_suspects(WERD_RES *word_res) {
|
||||
}
|
||||
}
|
||||
|
||||
inT16 Tesseract::count_alphas(const WERD_CHOICE &word) {
|
||||
int16_t Tesseract::count_alphas(const WERD_CHOICE &word) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < word.length(); ++i) {
|
||||
if (word.unicharset()->get_isalpha(word.unichar_id(i)))
|
||||
@ -405,7 +405,7 @@ inT16 Tesseract::count_alphas(const WERD_CHOICE &word) {
|
||||
}
|
||||
|
||||
|
||||
inT16 Tesseract::count_alphanums(const WERD_CHOICE &word) {
|
||||
int16_t Tesseract::count_alphanums(const WERD_CHOICE &word) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < word.length(); ++i) {
|
||||
if (word.unicharset()->get_isalpha(word.unichar_id(i)) ||
|
||||
|
@ -473,7 +473,7 @@ Pix* PageIterator::GetImage(PageIteratorLevel level, int padding,
|
||||
pixDilateBrick(resized_mask, resized_mask, 2 * padding + 1,
|
||||
2 * padding + 1);
|
||||
pixInvert(resized_mask, resized_mask);
|
||||
pixSetMasked(grey_pix, resized_mask, MAX_UINT32);
|
||||
pixSetMasked(grey_pix, resized_mask, UINT32_MAX);
|
||||
pixDestroy(&resized_mask);
|
||||
}
|
||||
return grey_pix;
|
||||
@ -493,9 +493,9 @@ bool PageIterator::Baseline(PageIteratorLevel level,
|
||||
? word->bounding_box()
|
||||
: row->bounding_box();
|
||||
int left = box.left();
|
||||
ICOORD startpt(left, static_cast<inT16>(row->base_line(left) + 0.5));
|
||||
ICOORD startpt(left, static_cast<int16_t>(row->base_line(left) + 0.5));
|
||||
int right = box.right();
|
||||
ICOORD endpt(right, static_cast<inT16>(row->base_line(right) + 0.5));
|
||||
ICOORD endpt(right, static_cast<int16_t>(row->base_line(right) + 0.5));
|
||||
// Rotate to image coordinates and convert to global image coords.
|
||||
startpt.rotate(it_->block()->block->re_rotation());
|
||||
endpt.rotate(it_->block()->block->re_rotation());
|
||||
|
@ -71,7 +71,7 @@ static Pix* RemoveEnclosingCircle(Pix* pixs) {
|
||||
l_int32 max_count;
|
||||
pixCountConnComp(pixt, 8, &max_count);
|
||||
// The count has to go up before we start looking for the minimum.
|
||||
l_int32 min_count = MAX_INT32;
|
||||
l_int32 min_count = INT32_MAX;
|
||||
Pix* pixout = NULL;
|
||||
for (int i = 1; i < kMaxCircleErosions; i++) {
|
||||
pixDestroy(&pixt);
|
||||
|
@ -395,7 +395,7 @@ void pgeditor_show_point( // display coords
|
||||
|
||||
namespace tesseract {
|
||||
BOOL8 Tesseract::process_cmd_win_event( // UI command semantics
|
||||
inT32 cmd_event, // which menu item?
|
||||
int32_t cmd_event, // which menu item?
|
||||
char *new_value // any prompt data
|
||||
) {
|
||||
char msg[160];
|
||||
@ -820,19 +820,19 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) {
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
Note the double coercions of(COLOUR)((inT32)editor_image_word_bb_color)
|
||||
Note the double coercions of(COLOUR)((int32_t)editor_image_word_bb_color)
|
||||
etc. are to keep the compiler happy.
|
||||
*/
|
||||
// display bounding box
|
||||
if (word->display_flag(DF_BOX)) {
|
||||
word->bounding_box().plot(image_win,
|
||||
(ScrollView::Color)((inT32)
|
||||
(ScrollView::Color)((int32_t)
|
||||
editor_image_word_bb_color),
|
||||
(ScrollView::Color)((inT32)
|
||||
(ScrollView::Color)((int32_t)
|
||||
editor_image_word_bb_color));
|
||||
|
||||
ScrollView::Color c = (ScrollView::Color)
|
||||
((inT32) editor_image_blob_bb_color);
|
||||
((int32_t) editor_image_blob_bb_color);
|
||||
image_win->Pen(c);
|
||||
c_it.set_to_list(word->cblob_list());
|
||||
for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward())
|
||||
@ -907,8 +907,8 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) {
|
||||
|
||||
if (!displayed_something) // display BBox anyway
|
||||
word->bounding_box().plot(image_win,
|
||||
(ScrollView::Color)((inT32) editor_image_word_bb_color),
|
||||
(ScrollView::Color)((inT32)
|
||||
(ScrollView::Color)((int32_t) editor_image_word_bb_color),
|
||||
(ScrollView::Color)((int32_t)
|
||||
editor_image_word_bb_color));
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
const inT16 kMaxBoxEdgeDiff = 2;
|
||||
const int16_t kMaxBoxEdgeDiff = 2;
|
||||
|
||||
// Sets flags necessary for recognition in the training mode.
|
||||
// Opens and returns the pointer to the output file.
|
||||
|
@ -54,7 +54,7 @@ CLISTIZEH (STRING) CLISTIZE (STRING)
|
||||
*************************************************************************/
|
||||
|
||||
namespace tesseract {
|
||||
void Tesseract::set_done(WERD_RES *word, inT16 pass) {
|
||||
void Tesseract::set_done(WERD_RES *word, int16_t pass) {
|
||||
word->done = word->tess_accepted &&
|
||||
(strchr(word->best_choice->unichar_string().string(), ' ') == NULL);
|
||||
bool word_is_ambig = word->best_choice->dangerous_ambig_found();
|
||||
@ -85,7 +85,7 @@ void Tesseract::set_done(WERD_RES *word, inT16 pass) {
|
||||
*
|
||||
* Sets a reject map for the word.
|
||||
*************************************************************************/
|
||||
void Tesseract::make_reject_map(WERD_RES *word, ROW *row, inT16 pass) {
|
||||
void Tesseract::make_reject_map(WERD_RES *word, ROW *row, int16_t pass) {
|
||||
int i;
|
||||
int offset;
|
||||
|
||||
@ -176,8 +176,8 @@ void Tesseract::make_reject_map(WERD_RES *word, ROW *row, inT16 pass) {
|
||||
|
||||
|
||||
void reject_blanks(WERD_RES *word) {
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
|
||||
for (i = 0, offset = 0; word->best_choice->unichar_string()[offset] != '\0';
|
||||
offset += word->best_choice->unichar_lengths()[i], i += 1) {
|
||||
@ -189,8 +189,8 @@ void reject_blanks(WERD_RES *word) {
|
||||
|
||||
namespace tesseract {
|
||||
void Tesseract::reject_I_1_L(WERD_RES *word) {
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
|
||||
for (i = 0, offset = 0; word->best_choice->unichar_string()[offset] != '\0';
|
||||
offset += word->best_choice->unichar_lengths()[i], i += 1) {
|
||||
@ -292,11 +292,11 @@ void Tesseract::reject_edge_blobs(WERD_RES *word) {
|
||||
BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) {
|
||||
const char *word;
|
||||
const char *lengths;
|
||||
inT16 word_len; //its length
|
||||
inT16 first_alphanum_index_;
|
||||
inT16 first_alphanum_offset_;
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
int16_t word_len; //its length
|
||||
int16_t first_alphanum_index_;
|
||||
int16_t first_alphanum_offset_;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
BOOL8 non_conflict_set_char; //non conf set a/n?
|
||||
BOOL8 conflict = FALSE;
|
||||
BOOL8 allow_1s;
|
||||
@ -425,7 +425,7 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) {
|
||||
allow_1s = (alpha_count (word, lengths) == 0) ||
|
||||
(word_res->best_choice->permuter () == NUMBER_PERM);
|
||||
|
||||
inT16 offset;
|
||||
int16_t offset;
|
||||
conflict = FALSE;
|
||||
for (i = 0, offset = 0; word[offset] != '\0';
|
||||
offset += word_res->best_choice->unichar_lengths()[i++]) {
|
||||
@ -466,10 +466,10 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) {
|
||||
}
|
||||
|
||||
|
||||
inT16 Tesseract::first_alphanum_index(const char *word,
|
||||
int16_t Tesseract::first_alphanum_index(const char *word,
|
||||
const char *word_lengths) {
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
|
||||
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
|
||||
if (unicharset.get_isalpha(word + offset, word_lengths[i]) ||
|
||||
@ -479,10 +479,10 @@ inT16 Tesseract::first_alphanum_index(const char *word,
|
||||
return -1;
|
||||
}
|
||||
|
||||
inT16 Tesseract::first_alphanum_offset(const char *word,
|
||||
int16_t Tesseract::first_alphanum_offset(const char *word,
|
||||
const char *word_lengths) {
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
|
||||
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
|
||||
if (unicharset.get_isalpha(word + offset, word_lengths[i]) ||
|
||||
@ -492,11 +492,11 @@ inT16 Tesseract::first_alphanum_offset(const char *word,
|
||||
return -1;
|
||||
}
|
||||
|
||||
inT16 Tesseract::alpha_count(const char *word,
|
||||
int16_t Tesseract::alpha_count(const char *word,
|
||||
const char *word_lengths) {
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
inT16 count = 0;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
int16_t count = 0;
|
||||
|
||||
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
|
||||
if (unicharset.get_isalpha (word + offset, word_lengths[i]))
|
||||
@ -508,8 +508,8 @@ inT16 Tesseract::alpha_count(const char *word,
|
||||
|
||||
BOOL8 Tesseract::word_contains_non_1_digit(const char *word,
|
||||
const char *word_lengths) {
|
||||
inT16 i;
|
||||
inT16 offset;
|
||||
int16_t i;
|
||||
int16_t offset;
|
||||
|
||||
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
|
||||
if (unicharset.get_isdigit (word + offset, word_lengths[i]) &&
|
||||
@ -555,7 +555,7 @@ void Tesseract::dont_allow_1Il(WERD_RES *word) {
|
||||
}
|
||||
|
||||
|
||||
inT16 Tesseract::count_alphanums(WERD_RES *word_res) {
|
||||
int16_t Tesseract::count_alphanums(WERD_RES *word_res) {
|
||||
int count = 0;
|
||||
const WERD_CHOICE *best_choice = word_res->best_choice;
|
||||
for (int i = 0; i < word_res->reject_map.length(); ++i) {
|
||||
@ -580,8 +580,8 @@ void Tesseract::reject_mostly_rejects(WERD_RES *word) {
|
||||
|
||||
|
||||
BOOL8 Tesseract::repeated_nonalphanum_wd(WERD_RES *word, ROW *row) {
|
||||
inT16 char_quality;
|
||||
inT16 accepted_char_quality;
|
||||
int16_t char_quality;
|
||||
int16_t accepted_char_quality;
|
||||
|
||||
if (word->best_choice->unichar_lengths().length() <= 1)
|
||||
return FALSE;
|
||||
@ -604,7 +604,7 @@ BOOL8 Tesseract::repeated_nonalphanum_wd(WERD_RES *word, ROW *row) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inT16 Tesseract::safe_dict_word(const WERD_RES *werd_res) {
|
||||
int16_t Tesseract::safe_dict_word(const WERD_RES *werd_res) {
|
||||
const WERD_CHOICE &word = *werd_res->best_choice;
|
||||
int dict_word_type = werd_res->tesseract->dict_word(word);
|
||||
return dict_word_type == DOC_DAWG_PERM ? 0 : dict_word_type;
|
||||
|
@ -678,7 +678,7 @@ bool ResultIterator::BidiDebug(int min_level) const {
|
||||
IntParam *p = ParamUtils::FindParam<IntParam>(
|
||||
"bidi_debug", GlobalParams()->int_params,
|
||||
tesseract_->params()->int_params);
|
||||
if (p != NULL) debug_level = (inT32)(*p);
|
||||
if (p != NULL) debug_level = (int32_t)(*p);
|
||||
return debug_level >= min_level;
|
||||
}
|
||||
|
||||
|
@ -699,11 +699,11 @@ void Tesseract::PrepareForPageseg() {
|
||||
// Find the max splitter strategy over all langs.
|
||||
ShiroRekhaSplitter::SplitStrategy max_pageseg_strategy =
|
||||
static_cast<ShiroRekhaSplitter::SplitStrategy>(
|
||||
static_cast<inT32>(pageseg_devanagari_split_strategy));
|
||||
static_cast<int32_t>(pageseg_devanagari_split_strategy));
|
||||
for (int i = 0; i < sub_langs_.size(); ++i) {
|
||||
ShiroRekhaSplitter::SplitStrategy pageseg_strategy =
|
||||
static_cast<ShiroRekhaSplitter::SplitStrategy>(
|
||||
static_cast<inT32>(sub_langs_[i]->pageseg_devanagari_split_strategy));
|
||||
static_cast<int32_t>(sub_langs_[i]->pageseg_devanagari_split_strategy));
|
||||
if (pageseg_strategy > max_pageseg_strategy)
|
||||
max_pageseg_strategy = pageseg_strategy;
|
||||
pixDestroy(&sub_langs_[i]->pix_binary_);
|
||||
@ -730,11 +730,11 @@ void Tesseract::PrepareForTessOCR(BLOCK_LIST* block_list,
|
||||
// Find the max splitter strategy over all langs.
|
||||
ShiroRekhaSplitter::SplitStrategy max_ocr_strategy =
|
||||
static_cast<ShiroRekhaSplitter::SplitStrategy>(
|
||||
static_cast<inT32>(ocr_devanagari_split_strategy));
|
||||
static_cast<int32_t>(ocr_devanagari_split_strategy));
|
||||
for (int i = 0; i < sub_langs_.size(); ++i) {
|
||||
ShiroRekhaSplitter::SplitStrategy ocr_strategy =
|
||||
static_cast<ShiroRekhaSplitter::SplitStrategy>(
|
||||
static_cast<inT32>(sub_langs_[i]->ocr_devanagari_split_strategy));
|
||||
static_cast<int32_t>(sub_langs_[i]->ocr_devanagari_split_strategy));
|
||||
if (ocr_strategy > max_ocr_strategy)
|
||||
max_ocr_strategy = ocr_strategy;
|
||||
}
|
||||
|
@ -118,14 +118,14 @@ struct TesseractStats {
|
||||
last_char_was_tilde(false),
|
||||
write_results_empty_block(true) {}
|
||||
|
||||
inT32 adaption_word_number;
|
||||
inT16 doc_blob_quality;
|
||||
inT16 doc_outline_errs;
|
||||
inT16 doc_char_quality;
|
||||
inT16 good_char_count;
|
||||
inT16 doc_good_char_quality;
|
||||
inT32 word_count; // count of word in the document
|
||||
inT32 dict_words; // number of dicitionary words in the document
|
||||
int32_t adaption_word_number;
|
||||
int16_t doc_blob_quality;
|
||||
int16_t doc_outline_errs;
|
||||
int16_t doc_char_quality;
|
||||
int16_t good_char_count;
|
||||
int16_t doc_good_char_quality;
|
||||
int32_t word_count; // count of word in the document
|
||||
int32_t dict_words; // number of dicitionary words in the document
|
||||
STRING dump_words_str; // accumulator used by dump_words()
|
||||
// Flags used by write_results()
|
||||
bool tilde_crunch_written;
|
||||
@ -499,8 +499,8 @@ class Tesseract : public Wordrec {
|
||||
UNICHAR_ID get_rep_char(WERD_RES *word); // what char is repeated?
|
||||
BOOL8 acceptable_number_string(const char *s,
|
||||
const char *lengths);
|
||||
inT16 count_alphanums(const WERD_CHOICE &word);
|
||||
inT16 count_alphas(const WERD_CHOICE &word);
|
||||
int16_t count_alphanums(const WERD_CHOICE &word);
|
||||
int16_t count_alphas(const WERD_CHOICE &word);
|
||||
//// tessedit.h ////////////////////////////////////////////////////////
|
||||
void read_config_file(const char *filename, SetParamConstraint constraint);
|
||||
// Initialize for potentially a set of languages defined by the language
|
||||
@ -572,7 +572,7 @@ class Tesseract : public Wordrec {
|
||||
void process_image_event( // action in image win
|
||||
const SVEvent &event);
|
||||
BOOL8 process_cmd_win_event( // UI command semantics
|
||||
inT32 cmd_event, // which menu item?
|
||||
int32_t cmd_event, // which menu item?
|
||||
char *new_value // any prompt data
|
||||
);
|
||||
void debug_word(PAGE_RES* page_res, const TBOX &selection_box);
|
||||
@ -588,18 +588,18 @@ class Tesseract : public Wordrec {
|
||||
void blob_feature_display(PAGE_RES* page_res, const TBOX& selection_box);
|
||||
//// reject.h //////////////////////////////////////////////////////////
|
||||
// make rej map for word
|
||||
void make_reject_map(WERD_RES *word, ROW *row, inT16 pass);
|
||||
void make_reject_map(WERD_RES *word, ROW *row, int16_t pass);
|
||||
BOOL8 one_ell_conflict(WERD_RES *word_res, BOOL8 update_map);
|
||||
inT16 first_alphanum_index(const char *word,
|
||||
int16_t first_alphanum_index(const char *word,
|
||||
const char *word_lengths);
|
||||
inT16 first_alphanum_offset(const char *word,
|
||||
int16_t first_alphanum_offset(const char *word,
|
||||
const char *word_lengths);
|
||||
inT16 alpha_count(const char *word,
|
||||
int16_t alpha_count(const char *word,
|
||||
const char *word_lengths);
|
||||
BOOL8 word_contains_non_1_digit(const char *word,
|
||||
const char *word_lengths);
|
||||
void dont_allow_1Il(WERD_RES *word);
|
||||
inT16 count_alphanums( //how many alphanums
|
||||
int16_t count_alphanums( //how many alphanums
|
||||
WERD_RES *word);
|
||||
void flip_0O(WERD_RES *word);
|
||||
BOOL8 non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id);
|
||||
@ -611,8 +611,8 @@ class Tesseract : public Wordrec {
|
||||
void nn_recover_rejects(WERD_RES *word, ROW *row);
|
||||
void set_done( //set done flag
|
||||
WERD_RES *word,
|
||||
inT16 pass);
|
||||
inT16 safe_dict_word(const WERD_RES *werd_res); // is best_choice in dict?
|
||||
int16_t pass);
|
||||
int16_t safe_dict_word(const WERD_RES *werd_res); // is best_choice in dict?
|
||||
void flip_hyphens(WERD_RES *word);
|
||||
void reject_I_1_L(WERD_RES *word);
|
||||
void reject_edge_blobs(WERD_RES *word);
|
||||
@ -620,7 +620,7 @@ class Tesseract : public Wordrec {
|
||||
//// adaptions.h ///////////////////////////////////////////////////////
|
||||
BOOL8 word_adaptable( //should we adapt?
|
||||
WERD_RES *word,
|
||||
uinT16 mode);
|
||||
uint16_t mode);
|
||||
|
||||
//// tfacepp.cpp ///////////////////////////////////////////////////////
|
||||
void recog_word_recursive(WERD_RES* word);
|
||||
@ -635,20 +635,20 @@ class Tesseract : public Wordrec {
|
||||
BlamerBundle *orig_bb) const;
|
||||
//// fixspace.cpp ///////////////////////////////////////////////////////
|
||||
BOOL8 digit_or_numeric_punct(WERD_RES *word, int char_position);
|
||||
inT16 eval_word_spacing(WERD_RES_LIST &word_res_list);
|
||||
int16_t eval_word_spacing(WERD_RES_LIST &word_res_list);
|
||||
void match_current_words(WERD_RES_LIST &words, ROW *row, BLOCK* block);
|
||||
inT16 fp_eval_word_spacing(WERD_RES_LIST &word_res_list);
|
||||
int16_t fp_eval_word_spacing(WERD_RES_LIST &word_res_list);
|
||||
void fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK* block);
|
||||
void fix_fuzzy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK* block);
|
||||
void fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK* block);
|
||||
void fix_fuzzy_spaces( //find fuzzy words
|
||||
ETEXT_DESC *monitor, //progress monitor
|
||||
inT32 word_count, //count of words in doc
|
||||
int32_t word_count, //count of words in doc
|
||||
PAGE_RES *page_res);
|
||||
void dump_words(WERD_RES_LIST &perm, inT16 score,
|
||||
inT16 mode, BOOL8 improved);
|
||||
void dump_words(WERD_RES_LIST &perm, int16_t score,
|
||||
int16_t mode, BOOL8 improved);
|
||||
BOOL8 fixspace_thinks_word_done(WERD_RES *word);
|
||||
inT16 worst_noise_blob(WERD_RES *word_res, float *worst_noise_score);
|
||||
int16_t worst_noise_blob(WERD_RES *word_res, float *worst_noise_score);
|
||||
float blob_noise_score(TBLOB *blob);
|
||||
void break_noisiest_blob_word(WERD_RES_LIST &words);
|
||||
//// docqual.cpp ////////////////////////////////////////////////////////
|
||||
@ -666,15 +666,15 @@ class Tesseract : public Wordrec {
|
||||
BOOL8 good_quality_doc);
|
||||
void convert_bad_unlv_chs(WERD_RES *word_res);
|
||||
void tilde_delete(PAGE_RES_IT &page_res_it);
|
||||
inT16 word_blob_quality(WERD_RES *word, ROW *row);
|
||||
void word_char_quality(WERD_RES *word, ROW *row, inT16 *match_count,
|
||||
inT16 *accepted_match_count);
|
||||
int16_t word_blob_quality(WERD_RES *word, ROW *row);
|
||||
void word_char_quality(WERD_RES *word, ROW *row, int16_t *match_count,
|
||||
int16_t *accepted_match_count);
|
||||
void unrej_good_chs(WERD_RES *word, ROW *row);
|
||||
inT16 count_outline_errs(char c, inT16 outline_count);
|
||||
inT16 word_outline_errs(WERD_RES *word);
|
||||
int16_t count_outline_errs(char c, int16_t outline_count);
|
||||
int16_t word_outline_errs(WERD_RES *word);
|
||||
BOOL8 terrible_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_level);
|
||||
CRUNCH_MODE word_deletable(WERD_RES *word, inT16 &delete_mode);
|
||||
inT16 failure_count(WERD_RES *word);
|
||||
CRUNCH_MODE word_deletable(WERD_RES *word, int16_t &delete_mode);
|
||||
int16_t failure_count(WERD_RES *word);
|
||||
BOOL8 noise_outlines(TWERD *word);
|
||||
//// pagewalk.cpp ///////////////////////////////////////////////////////
|
||||
void
|
||||
|
@ -143,7 +143,7 @@ void Tesseract::recog_word_recursive(WERD_RES *word) {
|
||||
**********************************************************************/
|
||||
void Tesseract::split_and_recog_word(WERD_RES *word) {
|
||||
// Find the biggest blob gap in the chopped_word.
|
||||
int bestgap = -MAX_INT32;
|
||||
int bestgap = -INT32_MAX;
|
||||
int split_index = 0;
|
||||
for (int b = 1; b < word->chopped_word->NumBlobs(); ++b) {
|
||||
TBOX prev_box = word->chopped_word->blobs[b - 1]->bounding_box();
|
||||
|
@ -181,7 +181,7 @@ void ImageThresholder::SetImage(const Pix* pix) {
|
||||
// Caller must use pixDestroy to free the created Pix.
|
||||
/// Returns false on error.
|
||||
bool ImageThresholder::ThresholdToPix(PageSegMode pageseg_mode, Pix** pix) {
|
||||
if (image_width_ > MAX_INT16 || image_height_ > MAX_INT16) {
|
||||
if (image_width_ > INT16_MAX || image_height_ > INT16_MAX) {
|
||||
tprintf("Image too large: (%d, %d)\n", image_width_, image_height_);
|
||||
return false;
|
||||
}
|
||||
@ -301,13 +301,13 @@ void ImageThresholder::ThresholdRectToPix(Pix* src_pix,
|
||||
Pix** pix) const {
|
||||
PERF_COUNT_START("ThresholdRectToPix")
|
||||
*pix = pixCreate(rect_width_, rect_height_, 1);
|
||||
uinT32* pixdata = pixGetData(*pix);
|
||||
uint32_t* pixdata = pixGetData(*pix);
|
||||
int wpl = pixGetWpl(*pix);
|
||||
int src_wpl = pixGetWpl(src_pix);
|
||||
uinT32* srcdata = pixGetData(src_pix);
|
||||
uint32_t* srcdata = pixGetData(src_pix);
|
||||
for (int y = 0; y < rect_height_; ++y) {
|
||||
const uinT32* linedata = srcdata + (y + rect_top_) * src_wpl;
|
||||
uinT32* pixline = pixdata + y * wpl;
|
||||
const uint32_t* linedata = srcdata + (y + rect_top_) * src_wpl;
|
||||
uint32_t* pixline = pixdata + y * wpl;
|
||||
for (int x = 0; x < rect_width_; ++x) {
|
||||
bool white_result = true;
|
||||
for (int ch = 0; ch < num_channels; ++ch) {
|
||||
|
@ -317,7 +317,7 @@ void BlamerBundle::SetChopperBlame(const WERD_RES* word, bool debug) {
|
||||
int num_blobs = word->chopped_word->blobs.size();
|
||||
int box_index = 0;
|
||||
int blob_index = 0;
|
||||
inT16 truth_x = -1;
|
||||
int16_t truth_x = -1;
|
||||
while (box_index < truth_word_.length() && blob_index < num_blobs) {
|
||||
truth_x = norm_truth_word_.BlobBox(box_index).right();
|
||||
TBLOB * curr_blob = word->chopped_word->blobs[blob_index];
|
||||
@ -416,15 +416,15 @@ void BlamerBundle::SetupCorrectSegmentation(const TWERD* word, bool debug) {
|
||||
int num_blobs = word->NumBlobs();
|
||||
if (num_blobs == 0) return; // No blobs to play with.
|
||||
int blob_index = 0;
|
||||
inT16 next_box_x = word->blobs[blob_index]->bounding_box().right();
|
||||
int16_t next_box_x = word->blobs[blob_index]->bounding_box().right();
|
||||
for (int truth_idx = 0; blob_index < num_blobs &&
|
||||
truth_idx < norm_truth_word_.length();
|
||||
++blob_index) {
|
||||
++next_box_col;
|
||||
inT16 curr_box_x = next_box_x;
|
||||
int16_t curr_box_x = next_box_x;
|
||||
if (blob_index + 1 < num_blobs)
|
||||
next_box_x = word->blobs[blob_index + 1]->bounding_box().right();
|
||||
inT16 truth_x = norm_truth_word_.BlobBox(truth_idx).right();
|
||||
int16_t truth_x = norm_truth_word_.BlobBox(truth_idx).right();
|
||||
debug_str.add_str_int("Box x coord vs. truth: ", curr_box_x);
|
||||
debug_str.add_str_int(" ", truth_x);
|
||||
debug_str += "\n";
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "strngs.h"
|
||||
#include "tesscallback.h"
|
||||
|
||||
static const inT16 kBlamerBoxTolerance = 5;
|
||||
static const int16_t kBlamerBoxTolerance = 5;
|
||||
|
||||
// Enum for expressing the source of error.
|
||||
// Note: Please update kIncorrectResultReasonNames when modifying this enum.
|
||||
|
@ -118,11 +118,11 @@ void BLOBNBOX::chop( //chop blobs
|
||||
FCOORD rotation, //for landscape
|
||||
float xheight //of line
|
||||
) {
|
||||
inT16 blobcount; //no of blobs
|
||||
int16_t blobcount; //no of blobs
|
||||
BLOBNBOX *newblob; //fake blob
|
||||
BLOBNBOX *blob; //current blob
|
||||
inT16 blobindex; //number of chop
|
||||
inT16 leftx; //left edge of blob
|
||||
int16_t blobindex; //number of chop
|
||||
int16_t leftx; //left edge of blob
|
||||
float blobwidth; //width of each
|
||||
float rightx; //right edge to scan
|
||||
float ymin, ymax; //limits of new blob
|
||||
@ -131,14 +131,14 @@ void BLOBNBOX::chop( //chop blobs
|
||||
BLOBNBOX_IT blob_it; //blob iterator
|
||||
|
||||
//get no of chops
|
||||
blobcount = (inT16) floor (box.width () / xheight);
|
||||
blobcount = (int16_t) floor (box.width () / xheight);
|
||||
if (blobcount > 1 && cblob_ptr != NULL) {
|
||||
//width of each
|
||||
blobwidth = (float) (box.width () + 1) / blobcount;
|
||||
for (blobindex = blobcount - 1, rightx = box.right ();
|
||||
blobindex >= 0; blobindex--, rightx -= blobwidth) {
|
||||
ymin = (float) MAX_INT32;
|
||||
ymax = (float) -MAX_INT32;
|
||||
ymin = (float) INT32_MAX;
|
||||
ymax = (float) -INT32_MAX;
|
||||
blob_it = *start_it;
|
||||
do {
|
||||
blob = blob_it.data ();
|
||||
@ -150,11 +150,11 @@ void BLOBNBOX::chop( //chop blobs
|
||||
}
|
||||
while (blob != end_it->data ());
|
||||
if (ymin < ymax) {
|
||||
leftx = (inT16) floor (rightx - blobwidth);
|
||||
leftx = (int16_t) floor (rightx - blobwidth);
|
||||
if (leftx < box.left ())
|
||||
leftx = box.left (); //clip to real box
|
||||
bl = ICOORD (leftx, (inT16) floor (ymin));
|
||||
tr = ICOORD ((inT16) ceil (rightx), (inT16) ceil (ymax));
|
||||
bl = ICOORD (leftx, (int16_t) floor (ymin));
|
||||
tr = ICOORD ((int16_t) ceil (rightx), (int16_t) ceil (ymax));
|
||||
if (blobindex == 0)
|
||||
box = TBOX (bl, tr); //change box
|
||||
else {
|
||||
@ -175,7 +175,7 @@ void BLOBNBOX::chop( //chop blobs
|
||||
// indexed by BlobNeighbourDir.
|
||||
void BLOBNBOX::NeighbourGaps(int gaps[BND_COUNT]) const {
|
||||
for (int dir = 0; dir < BND_COUNT; ++dir) {
|
||||
gaps[dir] = MAX_INT16;
|
||||
gaps[dir] = INT16_MAX;
|
||||
BLOBNBOX* neighbour = neighbours_[dir];
|
||||
if (neighbour != NULL) {
|
||||
const TBOX& n_box = neighbour->bounding_box();
|
||||
@ -498,15 +498,15 @@ void find_cblob_limits( //get y limits
|
||||
FCOORD rotation, //for landscape
|
||||
float &ymin, //output y limits
|
||||
float &ymax) {
|
||||
inT16 stepindex; //current point
|
||||
int16_t stepindex; //current point
|
||||
ICOORD pos; //current coords
|
||||
ICOORD vec; //rotated step
|
||||
C_OUTLINE *outline; //current outline
|
||||
//outlines
|
||||
C_OUTLINE_IT out_it = blob->out_list ();
|
||||
|
||||
ymin = (float) MAX_INT32;
|
||||
ymax = (float) -MAX_INT32;
|
||||
ymin = (float) INT32_MAX;
|
||||
ymax = (float) -INT32_MAX;
|
||||
for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
|
||||
outline = out_it.data ();
|
||||
pos = outline->start_pos (); //get coords
|
||||
@ -537,15 +537,15 @@ void find_cblob_vlimits( //get y limits
|
||||
float rightx,
|
||||
float &ymin, //output y limits
|
||||
float &ymax) {
|
||||
inT16 stepindex; //current point
|
||||
int16_t stepindex; //current point
|
||||
ICOORD pos; //current coords
|
||||
ICOORD vec; //rotated step
|
||||
C_OUTLINE *outline; //current outline
|
||||
//outlines
|
||||
C_OUTLINE_IT out_it = blob->out_list ();
|
||||
|
||||
ymin = (float) MAX_INT32;
|
||||
ymax = (float) -MAX_INT32;
|
||||
ymin = (float) INT32_MAX;
|
||||
ymax = (float) -INT32_MAX;
|
||||
for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
|
||||
outline = out_it.data ();
|
||||
pos = outline->start_pos (); //get coords
|
||||
@ -574,15 +574,15 @@ void find_cblob_hlimits( //get x limits
|
||||
float topy,
|
||||
float &xmin, //output x limits
|
||||
float &xmax) {
|
||||
inT16 stepindex; //current point
|
||||
int16_t stepindex; //current point
|
||||
ICOORD pos; //current coords
|
||||
ICOORD vec; //rotated step
|
||||
C_OUTLINE *outline; //current outline
|
||||
//outlines
|
||||
C_OUTLINE_IT out_it = blob->out_list ();
|
||||
|
||||
xmin = (float) MAX_INT32;
|
||||
xmax = (float) -MAX_INT32;
|
||||
xmin = (float) INT32_MAX;
|
||||
xmax = (float) -INT32_MAX;
|
||||
for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
|
||||
outline = out_it.data ();
|
||||
pos = outline->start_pos (); //get coords
|
||||
@ -886,8 +886,8 @@ void vertical_coutline_projection( //project outlines
|
||||
) {
|
||||
ICOORD pos; //current point
|
||||
ICOORD step; //edge step
|
||||
inT32 length; //of outline
|
||||
inT16 stepindex; //current step
|
||||
int32_t length; //of outline
|
||||
int16_t stepindex; //current step
|
||||
C_OUTLINE_IT out_it = outline->child ();
|
||||
|
||||
pos = outline->start_pos ();
|
||||
|
@ -235,7 +235,7 @@ class BLOBNBOX:public ELIST_LINK
|
||||
red_box = new_box;
|
||||
reduced = true;
|
||||
}
|
||||
inT32 enclosed_area() const {
|
||||
int32_t enclosed_area() const {
|
||||
return area;
|
||||
}
|
||||
bool joined_to_prev() const {
|
||||
@ -510,13 +510,13 @@ class BLOBNBOX:public ELIST_LINK
|
||||
TabType right_tab_type_; // Indicates tab-stop assessment
|
||||
BlobRegionType region_type_; // Type of region this blob belongs to
|
||||
BlobTextFlowType flow_; // Quality of text flow.
|
||||
inT16 left_rule_; // x-coord of nearest but not crossing rule line
|
||||
inT16 right_rule_; // x-coord of nearest but not crossing rule line
|
||||
inT16 left_crossing_rule_; // x-coord of nearest or crossing rule line
|
||||
inT16 right_crossing_rule_; // x-coord of nearest or crossing rule line
|
||||
inT16 base_char_top_; // y-coord of top/bottom of diacritic base,
|
||||
inT16 base_char_bottom_; // if it exists else top/bottom of this blob.
|
||||
inT16 baseline_y_; // Estimate of baseline position.
|
||||
int16_t left_rule_; // x-coord of nearest but not crossing rule line
|
||||
int16_t right_rule_; // x-coord of nearest but not crossing rule line
|
||||
int16_t left_crossing_rule_; // x-coord of nearest or crossing rule line
|
||||
int16_t right_crossing_rule_; // x-coord of nearest or crossing rule line
|
||||
int16_t base_char_top_; // y-coord of top/bottom of diacritic base,
|
||||
int16_t base_char_bottom_; // if it exists else top/bottom of this blob.
|
||||
int16_t baseline_y_; // Estimate of baseline position.
|
||||
int line_crossings_; // Number of line intersections touched.
|
||||
BLOBNBOX* base_char_blob_; // The blob that was the base char.
|
||||
float horz_stroke_width_; // Median horizontal stroke width
|
||||
@ -641,8 +641,8 @@ class TO_ROW: public ELIST2_LINK
|
||||
BOOL8 merged;
|
||||
BOOL8 all_caps; // had no ascenders
|
||||
BOOL8 used_dm_model; // in guessing pitch
|
||||
inT16 projection_left; // start of projection
|
||||
inT16 projection_right; // start of projection
|
||||
int16_t projection_left; // start of projection
|
||||
int16_t projection_right; // start of projection
|
||||
PITCH_TYPE pitch_decision; // how strong is decision
|
||||
float fixed_pitch; // pitch or 0
|
||||
float fp_space; // sp if fixed pitch
|
||||
@ -656,9 +656,9 @@ class TO_ROW: public ELIST2_LINK
|
||||
float descdrop; // descenders
|
||||
float body_size; // of CJK characters. Assumed to be
|
||||
// xheight+ascrise for non-CJK text.
|
||||
inT32 min_space; // min size for real space
|
||||
inT32 max_nonspace; // max size of non-space
|
||||
inT32 space_threshold; // space vs nonspace
|
||||
int32_t min_space; // min size for real space
|
||||
int32_t max_nonspace; // max size of non-space
|
||||
int32_t space_threshold; // space vs nonspace
|
||||
float kern_size; // average non-space
|
||||
float space_size; // average space
|
||||
WERD_LIST rep_words; // repeated chars
|
||||
@ -785,8 +785,8 @@ class TO_BLOCK:public ELIST_LINK
|
||||
float fixed_pitch; //pitch or 0
|
||||
float kern_size; //average non-space
|
||||
float space_size; //average space
|
||||
inT32 min_space; //min definite space
|
||||
inT32 max_nonspace; //max definite
|
||||
int32_t min_space; //min definite space
|
||||
int32_t max_nonspace; //max definite
|
||||
float fp_space; //sp if fixed pitch
|
||||
float fp_nonsp; //nonsp if fixed pitch
|
||||
float pr_space; //sp if prop
|
||||
|
@ -223,10 +223,10 @@ void TESSLINE::SetupFromPos() {
|
||||
|
||||
// Recomputes the bounding box from the points in the loop.
|
||||
void TESSLINE::ComputeBoundingBox() {
|
||||
int minx = MAX_INT32;
|
||||
int miny = MAX_INT32;
|
||||
int maxx = -MAX_INT32;
|
||||
int maxy = -MAX_INT32;
|
||||
int minx = INT32_MAX;
|
||||
int miny = INT32_MAX;
|
||||
int maxx = -INT32_MAX;
|
||||
int maxy = -INT32_MAX;
|
||||
|
||||
// Find boundaries.
|
||||
start = loop->pos;
|
||||
@ -258,8 +258,8 @@ void TESSLINE::ComputeBoundingBox() {
|
||||
// have to divide by the modulus of vec.
|
||||
void TESSLINE::MinMaxCrossProduct(const TPOINT vec,
|
||||
int* min_xp, int* max_xp) const {
|
||||
*min_xp = MAX_INT32;
|
||||
*max_xp = MIN_INT32;
|
||||
*min_xp = INT32_MAX;
|
||||
*max_xp = INT32_MIN;
|
||||
EDGEPT* this_edge = loop;
|
||||
do {
|
||||
if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) {
|
||||
@ -940,8 +940,8 @@ bool divisible_blob(TBLOB *blob, bool italic_blob, TPOINT* location) {
|
||||
if (outline1->is_hole)
|
||||
continue; // Holes do not count as separable.
|
||||
TPOINT mid_pt1(
|
||||
static_cast<inT16>((outline1->topleft.x + outline1->botright.x) / 2),
|
||||
static_cast<inT16>((outline1->topleft.y + outline1->botright.y) / 2));
|
||||
static_cast<int16_t>((outline1->topleft.x + outline1->botright.x) / 2),
|
||||
static_cast<int16_t>((outline1->topleft.y + outline1->botright.y) / 2));
|
||||
int mid_prod1 = CROSS(mid_pt1, vertical);
|
||||
int min_prod1, max_prod1;
|
||||
outline1->MinMaxCrossProduct(vertical, &min_prod1, &max_prod1);
|
||||
@ -950,8 +950,8 @@ bool divisible_blob(TBLOB *blob, bool italic_blob, TPOINT* location) {
|
||||
if (outline2->is_hole)
|
||||
continue; // Holes do not count as separable.
|
||||
TPOINT mid_pt2(
|
||||
static_cast<inT16>((outline2->topleft.x + outline2->botright.x) / 2),
|
||||
static_cast<inT16>((outline2->topleft.y + outline2->botright.y) / 2));
|
||||
static_cast<int16_t>((outline2->topleft.x + outline2->botright.x) / 2),
|
||||
static_cast<int16_t>((outline2->topleft.y + outline2->botright.y) / 2));
|
||||
int mid_prod2 = CROSS(mid_pt2, vertical);
|
||||
int min_prod2, max_prod2;
|
||||
outline2->MinMaxCrossProduct(vertical, &min_prod2, &max_prod2);
|
||||
@ -991,8 +991,8 @@ void divide_blobs(TBLOB *blob, TBLOB *other_blob, bool italic_blob,
|
||||
|
||||
while (outline != NULL) {
|
||||
TPOINT mid_pt(
|
||||
static_cast<inT16>((outline->topleft.x + outline->botright.x) / 2),
|
||||
static_cast<inT16>((outline->topleft.y + outline->botright.y) / 2));
|
||||
static_cast<int16_t>((outline->topleft.x + outline->botright.x) / 2),
|
||||
static_cast<int16_t>((outline->topleft.y + outline->botright.y) / 2));
|
||||
int mid_prod = CROSS(mid_pt, vertical);
|
||||
if (mid_prod < location_prod) {
|
||||
// Outline is in left blob.
|
||||
|
@ -49,7 +49,7 @@ class WERD;
|
||||
|
||||
struct TPOINT {
|
||||
TPOINT(): x(0), y(0) {}
|
||||
TPOINT(inT16 vx, inT16 vy) : x(vx), y(vy) {}
|
||||
TPOINT(int16_t vx, int16_t vy) : x(vx), y(vy) {}
|
||||
TPOINT(const ICOORD &ic) : x(ic.x()), y(ic.y()) {}
|
||||
|
||||
void operator+=(const TPOINT& other) {
|
||||
@ -68,8 +68,8 @@ struct TPOINT {
|
||||
static bool IsCrossed(const TPOINT& a0, const TPOINT& a1, const TPOINT& b0,
|
||||
const TPOINT& b1);
|
||||
|
||||
inT16 x; // absolute x coord.
|
||||
inT16 y; // absolute y coord.
|
||||
int16_t x; // absolute x coord.
|
||||
int16_t y; // absolute y coord.
|
||||
};
|
||||
typedef TPOINT VECTOR; // structure for coordinates.
|
||||
|
||||
|
@ -35,8 +35,8 @@
|
||||
|
||||
bool read_unlv_file( //print list of sides
|
||||
STRING name, //basename of file
|
||||
inT32 xsize, //image size
|
||||
inT32 ysize, //image size
|
||||
int32_t xsize, //image size
|
||||
int32_t ysize, //image size
|
||||
BLOCK_LIST *blocks //output list
|
||||
) {
|
||||
FILE *pdfp; //file pointer
|
||||
@ -54,8 +54,8 @@ bool read_unlv_file( //print list of sides
|
||||
while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
|
||||
//make rect block
|
||||
block = new BLOCK (name.string (), TRUE, 0, 0,
|
||||
(inT16) x, (inT16) (ysize - y - height),
|
||||
(inT16) (x + width), (inT16) (ysize - y));
|
||||
(int16_t) x, (int16_t) (ysize - y - height),
|
||||
(int16_t) (x + width), (int16_t) (ysize - y));
|
||||
//on end of list
|
||||
block_it.add_to_end (block);
|
||||
}
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
bool read_unlv_file( //print list of sides
|
||||
STRING name, //basename of file
|
||||
inT32 xsize, //image size
|
||||
inT32 ysize, //image size
|
||||
int32_t xsize, //image size
|
||||
int32_t ysize, //image size
|
||||
BLOCK_LIST *blocks //output list
|
||||
);
|
||||
void FullPageBlock(int width, int height, BLOCK_LIST *blocks);
|
||||
|
@ -49,9 +49,9 @@ ICOORD C_OUTLINE::step_coords[4] = {
|
||||
*/
|
||||
|
||||
C_OUTLINE::C_OUTLINE(CRACKEDGE* startpt, ICOORD bot_left, ICOORD top_right,
|
||||
inT16 length)
|
||||
int16_t length)
|
||||
: box(bot_left, top_right), start(startpt->pos), offsets(NULL) {
|
||||
inT16 stepindex; //index to step
|
||||
int16_t stepindex; //index to step
|
||||
CRACKEDGE *edgept; //current point
|
||||
|
||||
stepcount = length; //no of steps
|
||||
@ -60,7 +60,7 @@ C_OUTLINE::C_OUTLINE(CRACKEDGE* startpt, ICOORD bot_left, ICOORD top_right,
|
||||
return;
|
||||
}
|
||||
//get memory
|
||||
steps = (uinT8 *) alloc_mem (step_mem());
|
||||
steps = (uint8_t *) alloc_mem (step_mem());
|
||||
memset(steps, 0, step_mem());
|
||||
edgept = startpt;
|
||||
|
||||
@ -80,21 +80,21 @@ C_OUTLINE::C_OUTLINE (
|
||||
//constructor
|
||||
//steps to copy
|
||||
ICOORD startpt, DIR128 * new_steps,
|
||||
inT16 length //length of loop
|
||||
int16_t length //length of loop
|
||||
):start (startpt), offsets(NULL) {
|
||||
inT8 dirdiff; //direction difference
|
||||
int8_t dirdiff; //direction difference
|
||||
DIR128 prevdir; //previous direction
|
||||
DIR128 dir; //current direction
|
||||
DIR128 lastdir; //dir of last step
|
||||
TBOX new_box; //easy bounding
|
||||
inT16 stepindex; //index to step
|
||||
inT16 srcindex; //source steps
|
||||
int16_t stepindex; //index to step
|
||||
int16_t srcindex; //source steps
|
||||
ICOORD pos; //current position
|
||||
|
||||
pos = startpt;
|
||||
stepcount = length; // No. of steps.
|
||||
ASSERT_HOST(length >= 0);
|
||||
steps = static_cast<uinT8*>(alloc_mem(step_mem())); // Get memory.
|
||||
steps = static_cast<uint8_t*>(alloc_mem(step_mem())); // Get memory.
|
||||
memset(steps, 0, step_mem());
|
||||
|
||||
lastdir = new_steps[length - 1];
|
||||
@ -140,15 +140,15 @@ inT16 length //length of loop
|
||||
|
||||
C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(NULL) {
|
||||
TBOX new_box; //easy bounding
|
||||
inT16 stepindex; //index to step
|
||||
inT16 dirdiff; //direction change
|
||||
int16_t stepindex; //index to step
|
||||
int16_t dirdiff; //direction change
|
||||
ICOORD pos; //current position
|
||||
ICOORD prevpos; //previous dest point
|
||||
|
||||
ICOORD destpos; //destination point
|
||||
inT16 destindex; //index to step
|
||||
int16_t destindex; //index to step
|
||||
DIR128 dir; //coded direction
|
||||
uinT8 new_step;
|
||||
uint8_t new_step;
|
||||
|
||||
stepcount = srcline->stepcount * 2;
|
||||
if (stepcount == 0) {
|
||||
@ -158,7 +158,7 @@ C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(NULL) {
|
||||
return;
|
||||
}
|
||||
//get memory
|
||||
steps = (uinT8 *) alloc_mem (step_mem());
|
||||
steps = (uint8_t *) alloc_mem (step_mem());
|
||||
memset(steps, 0, step_mem());
|
||||
|
||||
for (int iteration = 0; iteration < 2; ++iteration) {
|
||||
@ -252,10 +252,10 @@ void C_OUTLINE::FakeOutline(const TBOX& box, C_OUTLINE_LIST* outlines) {
|
||||
* Compute the area of the outline.
|
||||
*/
|
||||
|
||||
inT32 C_OUTLINE::area() const {
|
||||
int32_t C_OUTLINE::area() const {
|
||||
int stepindex; //current step
|
||||
inT32 total_steps; //steps to do
|
||||
inT32 total; //total area
|
||||
int32_t total_steps; //steps to do
|
||||
int32_t total; //total area
|
||||
ICOORD pos; //position of point
|
||||
ICOORD next_step; //step to next pix
|
||||
// We aren't going to modify the list, or its contents, but there is
|
||||
@ -286,8 +286,8 @@ inT32 C_OUTLINE::area() const {
|
||||
* Compute the perimeter of the outline and its first level children.
|
||||
*/
|
||||
|
||||
inT32 C_OUTLINE::perimeter() const {
|
||||
inT32 total_steps; // Return value.
|
||||
int32_t C_OUTLINE::perimeter() const {
|
||||
int32_t total_steps; // Return value.
|
||||
// We aren't going to modify the list, or its contents, but there is
|
||||
// no const iterator.
|
||||
C_OUTLINE_IT it(const_cast<C_OUTLINE_LIST*>(&children));
|
||||
@ -305,10 +305,10 @@ inT32 C_OUTLINE::perimeter() const {
|
||||
* Compute the area of the outline.
|
||||
*/
|
||||
|
||||
inT32 C_OUTLINE::outer_area() const {
|
||||
int32_t C_OUTLINE::outer_area() const {
|
||||
int stepindex; //current step
|
||||
inT32 total_steps; //steps to do
|
||||
inT32 total; //total area
|
||||
int32_t total_steps; //steps to do
|
||||
int32_t total; //total area
|
||||
ICOORD pos; //position of point
|
||||
ICOORD next_step; //step to next pix
|
||||
|
||||
@ -337,7 +337,7 @@ inT32 C_OUTLINE::outer_area() const {
|
||||
* @param threshold winding number on size
|
||||
*/
|
||||
|
||||
inT32 C_OUTLINE::count_transitions(inT32 threshold) {
|
||||
int32_t C_OUTLINE::count_transitions(int32_t threshold) {
|
||||
BOOL8 first_was_max_x; //what was first
|
||||
BOOL8 first_was_max_y;
|
||||
BOOL8 looking_for_max_x; //what is next
|
||||
@ -345,11 +345,11 @@ inT32 C_OUTLINE::count_transitions(inT32 threshold) {
|
||||
BOOL8 looking_for_max_y; //what is next
|
||||
BOOL8 looking_for_min_y;
|
||||
int stepindex; //current step
|
||||
inT32 total_steps; //steps to do
|
||||
int32_t total_steps; //steps to do
|
||||
//current limits
|
||||
inT32 max_x, min_x, max_y, min_y;
|
||||
inT32 initial_x, initial_y; //initial limits
|
||||
inT32 total; //total changes
|
||||
int32_t max_x, min_x, max_y, min_y;
|
||||
int32_t initial_x, initial_y; //initial limits
|
||||
int32_t total; //total changes
|
||||
ICOORD pos; //position of point
|
||||
ICOORD next_step; //step to next pix
|
||||
|
||||
@ -465,9 +465,9 @@ inT32 C_OUTLINE::count_transitions(inT32 threshold) {
|
||||
|
||||
BOOL8
|
||||
C_OUTLINE::operator<(const C_OUTLINE& other) const {
|
||||
inT16 count = 0; //winding count
|
||||
int16_t count = 0; //winding count
|
||||
ICOORD pos; //position of point
|
||||
inT32 stepindex; //index to cstep
|
||||
int32_t stepindex; //index to cstep
|
||||
|
||||
if (!box.overlap (other.box))
|
||||
return FALSE; //can't be contained
|
||||
@ -497,12 +497,12 @@ C_OUTLINE::operator<(const C_OUTLINE& other) const {
|
||||
* @param point point to wind around
|
||||
*/
|
||||
|
||||
inT16 C_OUTLINE::winding_number(ICOORD point) const {
|
||||
inT16 stepindex; //index to cstep
|
||||
inT16 count; //winding count
|
||||
int16_t C_OUTLINE::winding_number(ICOORD point) const {
|
||||
int16_t stepindex; //index to cstep
|
||||
int16_t count; //winding count
|
||||
ICOORD vec; //to current point
|
||||
ICOORD stepvec; //step vector
|
||||
inT32 cross; //cross product
|
||||
int32_t cross; //cross product
|
||||
|
||||
vec = start - point; //vector to it
|
||||
count = 0;
|
||||
@ -534,12 +534,12 @@ inT16 C_OUTLINE::winding_number(ICOORD point) const {
|
||||
* @return the sum direction delta of the outline.
|
||||
*/
|
||||
|
||||
inT16 C_OUTLINE::turn_direction() const { //winding number
|
||||
int16_t C_OUTLINE::turn_direction() const { //winding number
|
||||
DIR128 prevdir; //previous direction
|
||||
DIR128 dir; //current direction
|
||||
inT16 stepindex; //index to cstep
|
||||
inT8 dirdiff; //direction difference
|
||||
inT16 count; //winding count
|
||||
int16_t stepindex; //index to cstep
|
||||
int8_t dirdiff; //direction difference
|
||||
int16_t count; //winding count
|
||||
|
||||
if (stepcount == 0)
|
||||
return 128;
|
||||
@ -565,9 +565,9 @@ inT16 C_OUTLINE::turn_direction() const { //winding number
|
||||
void C_OUTLINE::reverse() { //reverse drection
|
||||
DIR128 halfturn = MODULUS / 2; //amount to shift
|
||||
DIR128 stepdir; //direction of step
|
||||
inT16 stepindex; //index to cstep
|
||||
inT16 farindex; //index to other side
|
||||
inT16 halfsteps; //half of stepcount
|
||||
int16_t stepindex; //index to cstep
|
||||
int16_t farindex; //index to other side
|
||||
int16_t halfsteps; //half of stepcount
|
||||
|
||||
halfsteps = (stepcount + 1) / 2;
|
||||
for (stepindex = 0; stepindex < halfsteps; stepindex++) {
|
||||
@ -794,9 +794,8 @@ void C_OUTLINE::ComputeEdgeOffsets(int threshold, Pix* pix) {
|
||||
(best_x - x) * best_diff;
|
||||
}
|
||||
offsets[s].offset_numerator =
|
||||
static_cast<inT8>(ClipToRange(offset, -MAX_INT8, MAX_INT8));
|
||||
offsets[s].pixel_diff = static_cast<uinT8>(ClipToRange(best_diff, 0 ,
|
||||
MAX_UINT8));
|
||||
ClipToRange<int>(offset, -INT8_MAX, INT8_MAX);
|
||||
offsets[s].pixel_diff = ClipToRange<int>(best_diff, 0, UINT8_MAX);
|
||||
if (negative) gradient = -gradient;
|
||||
// Compute gradient angle quantized to 256 directions, rotated by 64 (pi/2)
|
||||
// to convert from gradient direction to edge direction.
|
||||
@ -879,9 +878,8 @@ void C_OUTLINE::ComputeBinaryOffsets() {
|
||||
offset = pos_totals[dir_index] - best_diff * edge_pos;
|
||||
}
|
||||
offsets[s].offset_numerator =
|
||||
static_cast<inT8>(ClipToRange(offset, -MAX_INT8, MAX_INT8));
|
||||
offsets[s].pixel_diff = static_cast<uinT8>(ClipToRange(best_diff, 0 ,
|
||||
MAX_UINT8));
|
||||
ClipToRange<int>(offset, -INT8_MAX, INT8_MAX);
|
||||
offsets[s].pixel_diff = ClipToRange<int>(best_diff, 0, UINT8_MAX);
|
||||
// The direction is just the vector from start to end of the window.
|
||||
FCOORD direction(head_pos.x() - tail_pos.x(), head_pos.y() - tail_pos.y());
|
||||
offsets[s].direction = direction.to_direction();
|
||||
@ -942,7 +940,7 @@ void C_OUTLINE::render_outline(int left, int top, Pix* pix) const {
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
void C_OUTLINE::plot(ScrollView* window, ScrollView::Color colour) const {
|
||||
inT16 stepindex; // index to cstep
|
||||
int16_t stepindex; // index to cstep
|
||||
ICOORD pos; // current position
|
||||
DIR128 stepdir; // direction of step
|
||||
|
||||
@ -1015,7 +1013,7 @@ C_OUTLINE& C_OUTLINE::operator=(const C_OUTLINE& source) {
|
||||
if (steps != NULL)
|
||||
free_mem(steps);
|
||||
stepcount = source.stepcount;
|
||||
steps = (uinT8 *) alloc_mem (step_mem());
|
||||
steps = (uint8_t *) alloc_mem (step_mem());
|
||||
memmove (steps, source.steps, step_mem());
|
||||
if (!children.empty ())
|
||||
children.clear ();
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
class DENORM;
|
||||
|
||||
#define INTERSECTING MAX_INT16//no winding number
|
||||
#define INTERSECTING INT16_MAX//no winding number
|
||||
|
||||
//mask to get step
|
||||
#define STEP_MASK 3
|
||||
@ -57,9 +57,9 @@ enum C_OUTLINE_FLAGS
|
||||
// If the pixel_diff is zero, it means that the direction of the gradient
|
||||
// is in conflict with the step direction, so this step is to be ignored.
|
||||
struct EdgeOffset {
|
||||
inT8 offset_numerator;
|
||||
uinT8 pixel_diff;
|
||||
uinT8 direction;
|
||||
int8_t offset_numerator;
|
||||
uint8_t pixel_diff;
|
||||
uint8_t direction;
|
||||
};
|
||||
|
||||
class DLLSYM C_OUTLINE; //forward declaration
|
||||
@ -76,10 +76,10 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
|
||||
CRACKEDGE *startpt, //from edge detector
|
||||
ICOORD bot_left, //bounding box //length of loop
|
||||
ICOORD top_right,
|
||||
inT16 length);
|
||||
int16_t length);
|
||||
C_OUTLINE(ICOORD startpt, //start of loop
|
||||
DIR128 *new_steps, //steps in loop
|
||||
inT16 length); //length of loop
|
||||
int16_t length); //length of loop
|
||||
//outline to copy
|
||||
C_OUTLINE(C_OUTLINE *srcline, FCOORD rotation); //and rotate
|
||||
|
||||
@ -112,30 +112,30 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
|
||||
return box;
|
||||
}
|
||||
void set_step( //set a step
|
||||
inT16 stepindex, //index of step
|
||||
inT8 stepdir) { //chain code
|
||||
int16_t stepindex, //index of step
|
||||
int8_t stepdir) { //chain code
|
||||
int shift = stepindex%4 * 2;
|
||||
uinT8 mask = 3 << shift;
|
||||
uint8_t mask = 3 << shift;
|
||||
steps[stepindex/4] = ((stepdir << shift) & mask) |
|
||||
(steps[stepindex/4] & ~mask);
|
||||
//squeeze 4 into byte
|
||||
}
|
||||
void set_step( //set a step
|
||||
inT16 stepindex, //index of step
|
||||
int16_t stepindex, //index of step
|
||||
DIR128 stepdir) { //direction
|
||||
//clean it
|
||||
inT8 chaindir = stepdir.get_dir() >> (DIRBITS - 2);
|
||||
int8_t chaindir = stepdir.get_dir() >> (DIRBITS - 2);
|
||||
//difference
|
||||
set_step(stepindex, chaindir);
|
||||
//squeeze 4 into byte
|
||||
}
|
||||
|
||||
inT32 pathlength() const { //get path length
|
||||
int32_t pathlength() const { //get path length
|
||||
return stepcount;
|
||||
}
|
||||
// Return step at a given index as a DIR128.
|
||||
DIR128 step_dir(int index) const {
|
||||
return DIR128((inT16)(((steps[index/4] >> (index%4 * 2)) & STEP_MASK) <<
|
||||
return DIR128((int16_t)(((steps[index/4] >> (index%4 * 2)) & STEP_MASK) <<
|
||||
(DIRBITS - 2)));
|
||||
}
|
||||
// Return the step vector for the given outline position.
|
||||
@ -194,11 +194,11 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
|
||||
return (steps[index / 4] >> (index % 4 * 2)) & STEP_MASK;
|
||||
}
|
||||
|
||||
inT32 area() const; // Returns area of self and 1st level children.
|
||||
inT32 perimeter() const; // Total perimeter of self and 1st level children.
|
||||
inT32 outer_area() const; // Returns area of self only.
|
||||
inT32 count_transitions( //count maxima
|
||||
inT32 threshold); //size threshold
|
||||
int32_t area() const; // Returns area of self and 1st level children.
|
||||
int32_t perimeter() const; // Total perimeter of self and 1st level children.
|
||||
int32_t outer_area() const; // Returns area of self only.
|
||||
int32_t count_transitions( //count maxima
|
||||
int32_t threshold); //size threshold
|
||||
|
||||
BOOL8 operator< ( //containment test
|
||||
const C_OUTLINE & other) const;
|
||||
@ -207,10 +207,10 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
|
||||
{
|
||||
return other < *this; //use the < to do it
|
||||
}
|
||||
inT16 winding_number( //get winding number
|
||||
int16_t winding_number( //get winding number
|
||||
ICOORD testpt) const; //around this point
|
||||
//get direction
|
||||
inT16 turn_direction() const;
|
||||
int16_t turn_direction() const;
|
||||
void reverse(); //reverse direction
|
||||
|
||||
void move( // reposition outline
|
||||
@ -281,9 +281,9 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
|
||||
|
||||
TBOX box; // bounding box
|
||||
ICOORD start; // start coord
|
||||
inT16 stepcount; // no of steps
|
||||
int16_t stepcount; // no of steps
|
||||
BITS16 flags; // flags about outline
|
||||
uinT8 *steps; // step array
|
||||
uint8_t *steps; // step array
|
||||
EdgeOffset* offsets; // Higher precision edge.
|
||||
C_OUTLINE_LIST children; // child elements
|
||||
static ICOORD step_coords[4];
|
||||
|
@ -28,9 +28,9 @@ class CRACKEDGE {
|
||||
CRACKEDGE() {}
|
||||
|
||||
ICOORD pos; /*position of crack */
|
||||
inT8 stepx; //edge step
|
||||
inT8 stepy;
|
||||
inT8 stepdir; //chaincode
|
||||
int8_t stepx; //edge step
|
||||
int8_t stepy;
|
||||
int8_t stepdir; //chaincode
|
||||
CRACKEDGE *prev; /*previous point */
|
||||
CRACKEDGE *next; /*next point */
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ DPPoint* DPPoint::Solve(int min_step, int max_step, bool debug,
|
||||
for (int i = 0; i < size; ++i) {
|
||||
for (int offset = min_step; offset <= max_step; ++offset) {
|
||||
DPPoint* prev = offset <= i ? points + i - offset : NULL;
|
||||
inT64 new_cost = (points[i].*cost_func)(prev);
|
||||
int64_t new_cost = (points[i].*cost_func)(prev);
|
||||
if (points[i].best_prev_ != NULL && offset > min_step * 2 &&
|
||||
new_cost > points[i].total_cost_)
|
||||
break; // Find only the first minimum if going over twice the min.
|
||||
@ -65,25 +65,25 @@ DPPoint* DPPoint::Solve(int min_step, int max_step, bool debug,
|
||||
}
|
||||
|
||||
// A CostFunc that takes the variance of step into account in the cost.
|
||||
inT64 DPPoint::CostWithVariance(const DPPoint* prev) {
|
||||
int64_t DPPoint::CostWithVariance(const DPPoint* prev) {
|
||||
if (prev == NULL || prev == this) {
|
||||
UpdateIfBetter(0, 1, NULL, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int delta = this - prev;
|
||||
inT32 n = prev->n_ + 1;
|
||||
inT32 sig_x = prev->sig_x_ + delta;
|
||||
inT64 sig_xsq = prev->sig_xsq_ + delta * delta;
|
||||
inT64 cost = (sig_xsq - sig_x * sig_x / n) / n;
|
||||
int32_t n = prev->n_ + 1;
|
||||
int32_t sig_x = prev->sig_x_ + delta;
|
||||
int64_t sig_xsq = prev->sig_xsq_ + delta * delta;
|
||||
int64_t cost = (sig_xsq - sig_x * sig_x / n) / n;
|
||||
cost += prev->total_cost_;
|
||||
UpdateIfBetter(cost, prev->total_steps_ + 1, prev, n, sig_x, sig_xsq);
|
||||
return cost;
|
||||
}
|
||||
|
||||
// Update the other members if the cost is lower.
|
||||
void DPPoint::UpdateIfBetter(inT64 cost, inT32 steps, const DPPoint* prev,
|
||||
inT32 n, inT32 sig_x, inT64 sig_xsq) {
|
||||
void DPPoint::UpdateIfBetter(int64_t cost, int32_t steps, const DPPoint* prev,
|
||||
int32_t n, int32_t sig_x, int64_t sig_xsq) {
|
||||
if (cost < total_cost_) {
|
||||
total_cost_ = cost;
|
||||
total_steps_ = steps;
|
||||
|
@ -46,10 +46,10 @@ class DPPoint {
|
||||
// The cost function evaluates the total cost at this (excluding this's
|
||||
// local_cost) and if it beats this's total_cost, then
|
||||
// replace the appropriate values in this.
|
||||
typedef inT64 (DPPoint::*CostFunc)(const DPPoint* prev);
|
||||
typedef int64_t (DPPoint::*CostFunc)(const DPPoint* prev);
|
||||
|
||||
DPPoint()
|
||||
: local_cost_(0), total_cost_(MAX_INT32), total_steps_(1), best_prev_(NULL),
|
||||
: local_cost_(0), total_cost_(INT32_MAX), total_steps_(1), best_prev_(NULL),
|
||||
n_(0), sig_x_(0), sig_xsq_(0) {
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ class DPPoint {
|
||||
CostFunc cost_func, int size, DPPoint* points);
|
||||
|
||||
// A CostFunc that takes the variance of step into account in the cost.
|
||||
inT64 CostWithVariance(const DPPoint* prev);
|
||||
int64_t CostWithVariance(const DPPoint* prev);
|
||||
|
||||
// Accessors.
|
||||
int total_cost() const {
|
||||
@ -82,18 +82,18 @@ class DPPoint {
|
||||
// Code common to different cost functions.
|
||||
|
||||
// Update the other members if the cost is lower.
|
||||
void UpdateIfBetter(inT64 cost, inT32 steps, const DPPoint* prev,
|
||||
inT32 n, inT32 sig_x, inT64 sig_xsq);
|
||||
void UpdateIfBetter(int64_t cost, int32_t steps, const DPPoint* prev,
|
||||
int32_t n, int32_t sig_x, int64_t sig_xsq);
|
||||
|
||||
inT32 local_cost_; // Cost of this point on its own.
|
||||
inT32 total_cost_; // Sum of all costs in best path to here.
|
||||
int32_t local_cost_; // Cost of this point on its own.
|
||||
int32_t total_cost_; // Sum of all costs in best path to here.
|
||||
// During cost calculations local_cost is excluded.
|
||||
inT32 total_steps_; // Number of steps in best path to here.
|
||||
int32_t total_steps_; // Number of steps in best path to here.
|
||||
const DPPoint* best_prev_; // Pointer to prev point in best path from here.
|
||||
// Information for computing the variance part of the cost.
|
||||
inT32 n_; // Number of steps in best path to here for variance.
|
||||
inT32 sig_x_; // Sum of step sizes for computing variance.
|
||||
inT64 sig_xsq_; // Sum of squares of steps for computing variance.
|
||||
int32_t n_; // Number of steps in best path to here for variance.
|
||||
int32_t sig_x_; // Sum of step sizes for computing variance.
|
||||
int64_t sig_xsq_; // Sum of squares of steps for computing variance.
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
@ -60,7 +60,7 @@ bool FontInfoTable::DeSerialize(TFile* fp) {
|
||||
// properties as font_id.
|
||||
bool FontInfoTable::SetContainsFontProperties(
|
||||
int font_id, const GenericVector<ScoredFont>& font_set) const {
|
||||
uinT32 properties = get(font_id).properties;
|
||||
uint32_t properties = get(font_id).properties;
|
||||
for (int f = 0; f < font_set.size(); ++f) {
|
||||
if (get(font_set[f].fontinfo_id).properties == properties)
|
||||
return true;
|
||||
@ -73,7 +73,7 @@ bool FontInfoTable::SetContainsMultipleFontProperties(
|
||||
const GenericVector<ScoredFont>& font_set) const {
|
||||
if (font_set.empty()) return false;
|
||||
int first_font = font_set[0].fontinfo_id;
|
||||
uinT32 properties = get(first_font).properties;
|
||||
uint32_t properties = get(first_font).properties;
|
||||
for (int f = 1; f < font_set.size(); ++f) {
|
||||
if (get(font_set[f].fontinfo_id).properties != properties)
|
||||
return true;
|
||||
@ -150,7 +150,7 @@ void FontSetDeleteCallback(FontSet fs) {
|
||||
/*---------------------------------------------------------------------------*/
|
||||
// Callbacks used by UnicityTable to read/write FontInfo/FontSet structures.
|
||||
bool read_info(TFile* f, FontInfo* fi) {
|
||||
inT32 size;
|
||||
int32_t size;
|
||||
if (f->FReadEndian(&size, sizeof(size), 1) != 1) return false;
|
||||
char* font_name = new char[size + 1];
|
||||
fi->name = font_name;
|
||||
@ -162,7 +162,7 @@ bool read_info(TFile* f, FontInfo* fi) {
|
||||
}
|
||||
|
||||
bool write_info(FILE* f, const FontInfo& fi) {
|
||||
inT32 size = strlen(fi.name);
|
||||
int32_t size = strlen(fi.name);
|
||||
if (fwrite(&size, sizeof(size), 1, f) != 1) return false;
|
||||
if (static_cast<int>(fwrite(fi.name, sizeof(*fi.name), size, f)) != size)
|
||||
return false;
|
||||
@ -171,7 +171,7 @@ bool write_info(FILE* f, const FontInfo& fi) {
|
||||
}
|
||||
|
||||
bool read_spacing_info(TFile* f, FontInfo* fi) {
|
||||
inT32 vec_size, kern_size;
|
||||
int32_t vec_size, kern_size;
|
||||
if (f->FReadEndian(&vec_size, sizeof(vec_size), 1) != 1) return false;
|
||||
ASSERT_HOST(vec_size >= 0);
|
||||
if (vec_size == 0) return true;
|
||||
@ -199,12 +199,12 @@ bool read_spacing_info(TFile* f, FontInfo* fi) {
|
||||
}
|
||||
|
||||
bool write_spacing_info(FILE* f, const FontInfo& fi) {
|
||||
inT32 vec_size = (fi.spacing_vec == NULL) ? 0 : fi.spacing_vec->size();
|
||||
int32_t vec_size = (fi.spacing_vec == NULL) ? 0 : fi.spacing_vec->size();
|
||||
if (fwrite(&vec_size, sizeof(vec_size), 1, f) != 1) return false;
|
||||
inT16 x_gap_invalid = -1;
|
||||
int16_t x_gap_invalid = -1;
|
||||
for (int i = 0; i < vec_size; ++i) {
|
||||
FontSpacingInfo *fs = fi.spacing_vec->get(i);
|
||||
inT32 kern_size = (fs == NULL) ? -1 : fs->kerned_x_gaps.size();
|
||||
int32_t kern_size = (fs == NULL) ? -1 : fs->kerned_x_gaps.size();
|
||||
if (fs == NULL) {
|
||||
// Valid to have the identical fwrites. Writing invalid x-gaps.
|
||||
if (fwrite(&(x_gap_invalid), sizeof(x_gap_invalid), 1, f) != 1 ||
|
||||
|
@ -32,27 +32,27 @@ namespace tesseract {
|
||||
class BitVector;
|
||||
|
||||
// Simple struct to hold a font and a score. The scores come from the low-level
|
||||
// integer matcher, so they are in the uinT16 range. Fonts are an index to
|
||||
// integer matcher, so they are in the uint16_t range. Fonts are an index to
|
||||
// fontinfo_table.
|
||||
// These get copied around a lot, so best to keep them small.
|
||||
struct ScoredFont {
|
||||
ScoredFont() : fontinfo_id(-1), score(0) {}
|
||||
ScoredFont(int font_id, uinT16 classifier_score)
|
||||
ScoredFont(int font_id, uint16_t classifier_score)
|
||||
: fontinfo_id(font_id), score(classifier_score) {}
|
||||
|
||||
// Index into fontinfo table, but inside the classifier, may be a shapetable
|
||||
// index.
|
||||
inT32 fontinfo_id;
|
||||
int32_t fontinfo_id;
|
||||
// Raw score from the low-level classifier.
|
||||
uinT16 score;
|
||||
uint16_t score;
|
||||
};
|
||||
|
||||
// Struct for information about spacing between characters in a particular font.
|
||||
struct FontSpacingInfo {
|
||||
inT16 x_gap_before;
|
||||
inT16 x_gap_after;
|
||||
int16_t x_gap_before;
|
||||
int16_t x_gap_after;
|
||||
GenericVector<UNICHAR_ID> kerned_unichar_ids;
|
||||
GenericVector<inT16> kerned_x_gaps;
|
||||
GenericVector<int16_t> kerned_x_gaps;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -115,12 +115,12 @@ struct FontInfo {
|
||||
bool is_fraktur() const { return (properties & 16) != 0; }
|
||||
|
||||
char* name;
|
||||
uinT32 properties;
|
||||
uint32_t properties;
|
||||
// The universal_id is a field reserved for the initialization process
|
||||
// to assign a unique id number to all fonts loaded for the current
|
||||
// combination of languages. This id will then be returned by
|
||||
// ResultIterator::WordFontAttributes.
|
||||
inT32 universal_id;
|
||||
int32_t universal_id;
|
||||
// Horizontal spacing between characters (indexed by UNICHAR_ID).
|
||||
GenericVector<FontSpacingInfo *> *spacing_vec;
|
||||
};
|
||||
|
@ -45,9 +45,9 @@ namespace tesseract {
|
||||
WordFeature::WordFeature() : x_(0), y_(0), dir_(0) {
|
||||
}
|
||||
|
||||
WordFeature::WordFeature(const FCOORD& fcoord, uinT8 dir)
|
||||
WordFeature::WordFeature(const FCOORD& fcoord, uint8_t dir)
|
||||
: x_(IntCastRounded(fcoord.x())),
|
||||
y_(ClipToRange(IntCastRounded(fcoord.y()), 0, MAX_UINT8)),
|
||||
y_(ClipToRange<int>(IntCastRounded(fcoord.y()), 0, UINT8_MAX)),
|
||||
dir_(dir) {
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ bool ImageData::Serialize(TFile* fp) const {
|
||||
// WARNING: Will not work across different endian machines.
|
||||
if (!boxes_.Serialize(fp)) return false;
|
||||
if (!box_texts_.SerializeClasses(fp)) return false;
|
||||
inT8 vertical = vertical_text_;
|
||||
int8_t vertical = vertical_text_;
|
||||
if (fp->FWrite(&vertical, sizeof(vertical), 1) != 1) return false;
|
||||
return true;
|
||||
}
|
||||
@ -188,7 +188,7 @@ bool ImageData::DeSerialize(TFile* fp) {
|
||||
// WARNING: Will not work across different endian machines.
|
||||
if (!boxes_.DeSerialize(fp)) return false;
|
||||
if (!box_texts_.DeSerializeClasses(fp)) return false;
|
||||
inT8 vertical = 0;
|
||||
int8_t vertical = 0;
|
||||
if (fp->FRead(&vertical, sizeof(vertical), 1) != 1) return false;
|
||||
vertical_text_ = vertical != 0;
|
||||
return true;
|
||||
@ -197,14 +197,14 @@ bool ImageData::DeSerialize(TFile* fp) {
|
||||
// As DeSerialize, but only seeks past the data - hence a static method.
|
||||
bool ImageData::SkipDeSerialize(TFile* fp) {
|
||||
if (!STRING::SkipDeSerialize(fp)) return false;
|
||||
inT32 page_number;
|
||||
int32_t page_number;
|
||||
if (fp->FRead(&page_number, sizeof(page_number), 1) != 1) return false;
|
||||
if (!GenericVector<char>::SkipDeSerialize(fp)) return false;
|
||||
if (!STRING::SkipDeSerialize(fp)) return false;
|
||||
if (!STRING::SkipDeSerialize(fp)) return false;
|
||||
if (!GenericVector<TBOX>::SkipDeSerialize(fp)) return false;
|
||||
if (!GenericVector<STRING>::SkipDeSerializeClasses(fp)) return false;
|
||||
inT8 vertical = 0;
|
||||
int8_t vertical = 0;
|
||||
return fp->FRead(&vertical, sizeof(vertical), 1) == 1;
|
||||
}
|
||||
|
||||
@ -389,14 +389,14 @@ DocumentData::~DocumentData() {
|
||||
// Reads all the pages in the given lstmf filename to the cache. The reader
|
||||
// is used to read the file.
|
||||
bool DocumentData::LoadDocument(const char* filename, int start_page,
|
||||
inT64 max_memory, FileReader reader) {
|
||||
int64_t max_memory, FileReader reader) {
|
||||
SetDocument(filename, max_memory, reader);
|
||||
pages_offset_ = start_page;
|
||||
return ReCachePages();
|
||||
}
|
||||
|
||||
// Sets up the document, without actually loading it.
|
||||
void DocumentData::SetDocument(const char* filename, inT64 max_memory,
|
||||
void DocumentData::SetDocument(const char* filename, int64_t max_memory,
|
||||
FileReader reader) {
|
||||
SVAutoLock lock_p(&pages_mutex_);
|
||||
SVAutoLock lock(&general_mutex_);
|
||||
@ -486,9 +486,9 @@ bool DocumentData::IsPageAvailable(int index, ImageData** page) {
|
||||
|
||||
// Removes all pages from memory and frees the memory, but does not forget
|
||||
// the document metadata.
|
||||
inT64 DocumentData::UnCache() {
|
||||
int64_t DocumentData::UnCache() {
|
||||
SVAutoLock lock(&pages_mutex_);
|
||||
inT64 memory_saved = memory_used();
|
||||
int64_t memory_saved = memory_used();
|
||||
pages_.clear();
|
||||
pages_offset_ = -1;
|
||||
set_total_pages(-1);
|
||||
@ -564,7 +564,7 @@ bool DocumentData::ReCachePages() {
|
||||
}
|
||||
|
||||
// A collection of DocumentData that knows roughly how much memory it is using.
|
||||
DocumentCache::DocumentCache(inT64 max_memory)
|
||||
DocumentCache::DocumentCache(int64_t max_memory)
|
||||
: num_pages_per_doc_(0), max_memory_(max_memory) {}
|
||||
DocumentCache::~DocumentCache() {}
|
||||
|
||||
@ -574,7 +574,7 @@ bool DocumentCache::LoadDocuments(const GenericVector<STRING>& filenames,
|
||||
CachingStrategy cache_strategy,
|
||||
FileReader reader) {
|
||||
cache_strategy_ = cache_strategy;
|
||||
inT64 fair_share_memory = 0;
|
||||
int64_t fair_share_memory = 0;
|
||||
// In the round-robin case, each DocumentData handles restricting its content
|
||||
// to its fair share of memory. In the sequential case, DocumentCache
|
||||
// determines which DocumentDatas are held entirely in memory.
|
||||
@ -665,7 +665,7 @@ const ImageData* DocumentCache::GetPageSequential(int serial) {
|
||||
documents_[doc_index]->GetPage(serial % num_pages_per_doc_);
|
||||
// Count up total memory. Background loading makes it more complicated to
|
||||
// keep a running count.
|
||||
inT64 total_memory = 0;
|
||||
int64_t total_memory = 0;
|
||||
for (int d = 0; d < num_docs; ++d) {
|
||||
total_memory += documents_[d]->memory_used();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ enum CachingStrategy {
|
||||
class WordFeature {
|
||||
public:
|
||||
WordFeature();
|
||||
WordFeature(const FCOORD& fcoord, uinT8 dir);
|
||||
WordFeature(const FCOORD& fcoord, uint8_t dir);
|
||||
|
||||
// Computes the maximum x and y value in the features.
|
||||
static void ComputeSize(const GenericVector<WordFeature>& features,
|
||||
@ -76,9 +76,9 @@ class WordFeature {
|
||||
bool DeSerialize(bool swap, FILE* fp);
|
||||
|
||||
private:
|
||||
inT16 x_;
|
||||
uinT8 y_;
|
||||
uinT8 dir_;
|
||||
int16_t x_;
|
||||
uint8_t y_;
|
||||
uint8_t dir_;
|
||||
};
|
||||
|
||||
// A floating-point version of WordFeature, used as an intermediate during
|
||||
@ -190,7 +190,7 @@ class ImageData {
|
||||
|
||||
private:
|
||||
STRING imagefilename_; // File to read image from.
|
||||
inT32 page_number_; // Page number if multi-page tif or -1.
|
||||
int32_t page_number_; // Page number if multi-page tif or -1.
|
||||
GenericVector<char> image_data_; // PNG file data.
|
||||
STRING language_; // Language code for image.
|
||||
STRING transcription_; // UTF-8 ground truth of image.
|
||||
@ -209,10 +209,10 @@ class DocumentData {
|
||||
|
||||
// Reads all the pages in the given lstmf filename to the cache. The reader
|
||||
// is used to read the file.
|
||||
bool LoadDocument(const char* filename, int start_page, inT64 max_memory,
|
||||
bool LoadDocument(const char* filename, int start_page, int64_t max_memory,
|
||||
FileReader reader);
|
||||
// Sets up the document, without actually loading it.
|
||||
void SetDocument(const char* filename, inT64 max_memory, FileReader reader);
|
||||
void SetDocument(const char* filename, int64_t max_memory, FileReader reader);
|
||||
// Writes all the pages to the given filename. Returns false on error.
|
||||
bool SaveDocument(const char* filename, FileWriter writer);
|
||||
bool SaveToBuffer(GenericVector<char>* buffer);
|
||||
@ -228,7 +228,7 @@ class DocumentData {
|
||||
SVAutoLock lock(&general_mutex_);
|
||||
return total_pages_;
|
||||
}
|
||||
inT64 memory_used() const {
|
||||
int64_t memory_used() const {
|
||||
SVAutoLock lock(&general_mutex_);
|
||||
return memory_used_;
|
||||
}
|
||||
@ -263,7 +263,7 @@ class DocumentData {
|
||||
bool IsCached() const { return NumPages() >= 0; }
|
||||
// Removes all pages from memory and frees the memory, but does not forget
|
||||
// the document metadata. Returns the memory saved.
|
||||
inT64 UnCache();
|
||||
int64_t UnCache();
|
||||
// Shuffles all the pages in the document.
|
||||
void Shuffle();
|
||||
|
||||
@ -273,7 +273,7 @@ class DocumentData {
|
||||
SVAutoLock lock(&general_mutex_);
|
||||
total_pages_ = total;
|
||||
}
|
||||
void set_memory_used(inT64 memory_used) {
|
||||
void set_memory_used(int64_t memory_used) {
|
||||
SVAutoLock lock(&general_mutex_);
|
||||
memory_used_ = memory_used;
|
||||
}
|
||||
@ -291,9 +291,9 @@ class DocumentData {
|
||||
// Total number of pages in document (may exceed size of pages_.)
|
||||
int total_pages_;
|
||||
// Total of all pix sizes in the document.
|
||||
inT64 memory_used_;
|
||||
int64_t memory_used_;
|
||||
// Max memory to use at any time.
|
||||
inT64 max_memory_;
|
||||
int64_t max_memory_;
|
||||
// Saved reader from LoadDocument to allow re-caching.
|
||||
FileReader reader_;
|
||||
// Mutex that protects pages_ and pages_offset_ against multiple parallel
|
||||
@ -311,7 +311,7 @@ class DocumentData {
|
||||
// content.
|
||||
class DocumentCache {
|
||||
public:
|
||||
explicit DocumentCache(inT64 max_memory);
|
||||
explicit DocumentCache(int64_t max_memory);
|
||||
~DocumentCache();
|
||||
|
||||
// Deletes all existing documents from the cache.
|
||||
@ -368,7 +368,7 @@ class DocumentCache {
|
||||
// GetPageSequential to determine the document index.
|
||||
int num_pages_per_doc_;
|
||||
// Max memory allowed in this cache.
|
||||
inT64 max_memory_;
|
||||
int64_t max_memory_;
|
||||
};
|
||||
|
||||
} // namespace tesseract
|
||||
|
@ -132,7 +132,7 @@ const ICOORD & op2) {
|
||||
* Scalar product of 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline inT32
|
||||
inline int32_t
|
||||
operator% ( //scalar product
|
||||
const ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
@ -146,7 +146,7 @@ const ICOORD & op2) {
|
||||
* Cross product of 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline inT32 operator *( //cross product
|
||||
inline int32_t operator *( //cross product
|
||||
const ICOORD &op1, //operands
|
||||
const ICOORD &op2) {
|
||||
return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord;
|
||||
@ -161,7 +161,7 @@ inline inT32 operator *( //cross product
|
||||
|
||||
inline ICOORD operator *( //scalar multiply
|
||||
const ICOORD &op1, //operands
|
||||
inT16 scale) {
|
||||
int16_t scale) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
@ -171,7 +171,7 @@ inline ICOORD operator *( //scalar multiply
|
||||
|
||||
|
||||
inline ICOORD operator *( //scalar multiply
|
||||
inT16 scale,
|
||||
int16_t scale,
|
||||
const ICOORD &op1 //operands
|
||||
) {
|
||||
ICOORD result; //output
|
||||
@ -191,7 +191,7 @@ inline ICOORD operator *( //scalar multiply
|
||||
inline ICOORD &
|
||||
operator*= ( //scalar multiply
|
||||
ICOORD & op1, //operands
|
||||
inT16 scale) {
|
||||
int16_t scale) {
|
||||
op1.xcoord *= scale;
|
||||
op1.ycoord *= scale;
|
||||
return op1;
|
||||
@ -207,7 +207,7 @@ inT16 scale) {
|
||||
inline ICOORD
|
||||
operator/ ( //scalar divide
|
||||
const ICOORD & op1, //operands
|
||||
inT16 scale) {
|
||||
int16_t scale) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord / scale;
|
||||
@ -225,7 +225,7 @@ inT16 scale) {
|
||||
inline ICOORD &
|
||||
operator/= ( //scalar divide
|
||||
ICOORD & op1, //operands
|
||||
inT16 scale) {
|
||||
int16_t scale) {
|
||||
op1.xcoord /= scale;
|
||||
op1.ycoord /= scale;
|
||||
return op1;
|
||||
@ -240,10 +240,10 @@ inT16 scale) {
|
||||
|
||||
inline void ICOORD::rotate( //rotate by vector
|
||||
const FCOORD& vec) {
|
||||
inT16 tmp;
|
||||
int16_t tmp;
|
||||
|
||||
tmp = (inT16) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5);
|
||||
ycoord = (inT16) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5);
|
||||
tmp = (int16_t) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5);
|
||||
ycoord = (int16_t) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5);
|
||||
xcoord = tmp;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class LLSQ {
|
||||
void add(const LLSQ& other);
|
||||
// Deletes an element with a weight of 1.
|
||||
void remove(double x, double y);
|
||||
inT32 count() const { // no of elements
|
||||
int32_t count() const { // no of elements
|
||||
return static_cast<int>(total_weight + 0.5);
|
||||
}
|
||||
|
||||
|
@ -463,14 +463,14 @@ class GENERIC_2D_ARRAY {
|
||||
protected:
|
||||
// Factored helper to serialize the size.
|
||||
bool SerializeSize(FILE* fp) const {
|
||||
inT32 size = dim1_;
|
||||
int32_t size = dim1_;
|
||||
if (fwrite(&size, sizeof(size), 1, fp) != 1) return false;
|
||||
size = dim2_;
|
||||
if (fwrite(&size, sizeof(size), 1, fp) != 1) return false;
|
||||
return true;
|
||||
}
|
||||
bool SerializeSize(tesseract::TFile* fp) const {
|
||||
inT32 size = dim1_;
|
||||
int32_t size = dim1_;
|
||||
if (fp->FWrite(&size, sizeof(size), 1) != 1) return false;
|
||||
size = dim2_;
|
||||
if (fp->FWrite(&size, sizeof(size), 1) != 1) return false;
|
||||
@ -479,7 +479,7 @@ class GENERIC_2D_ARRAY {
|
||||
// Factored helper to deserialize the size.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool DeSerializeSize(bool swap, FILE* fp) {
|
||||
inT32 size1, size2;
|
||||
int32_t size1, size2;
|
||||
if (fread(&size1, sizeof(size1), 1, fp) != 1) return false;
|
||||
if (fread(&size2, sizeof(size2), 1, fp) != 1) return false;
|
||||
if (swap) {
|
||||
@ -490,7 +490,7 @@ class GENERIC_2D_ARRAY {
|
||||
return true;
|
||||
}
|
||||
bool DeSerializeSize(tesseract::TFile* fp) {
|
||||
inT32 size1, size2;
|
||||
int32_t size1, size2;
|
||||
if (fp->FReadEndian(&size1, sizeof(size1), 1) != 1) return false;
|
||||
if (fp->FReadEndian(&size2, sizeof(size2), 1) != 1) return false;
|
||||
Resize(size1, size2, empty_);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "mod128.h"
|
||||
|
||||
const inT16 idirtab[] = {
|
||||
const int16_t idirtab[] = {
|
||||
1000, 0, 998, 49, 995, 98, 989, 146,
|
||||
980, 195, 970, 242, 956, 290, 941, 336,
|
||||
923, 382, 903, 427, 881, 471, 857, 514,
|
||||
|
@ -33,33 +33,33 @@ class DLLSYM DIR128
|
||||
} //empty constructor
|
||||
|
||||
DIR128( //constructor
|
||||
inT16 value) { //value to assign
|
||||
int16_t value) { //value to assign
|
||||
value %= MODULUS; //modulo arithmetic
|
||||
if (value < 0)
|
||||
value += MODULUS; //done properly
|
||||
dir = (inT8) value;
|
||||
dir = (int8_t) value;
|
||||
}
|
||||
DIR128(const FCOORD fc); //quantize vector
|
||||
|
||||
DIR128 & operator= ( //assign of inT16
|
||||
inT16 value) { //value to assign
|
||||
DIR128 & operator= ( //assign of int16_t
|
||||
int16_t value) { //value to assign
|
||||
value %= MODULUS; //modulo arithmetic
|
||||
if (value < 0)
|
||||
value += MODULUS; //done properly
|
||||
dir = (inT8) value;
|
||||
dir = (int8_t) value;
|
||||
return *this;
|
||||
}
|
||||
inT8 operator- ( //subtraction
|
||||
int8_t operator- ( //subtraction
|
||||
const DIR128 & minus) const//for signed result
|
||||
{
|
||||
//result
|
||||
inT16 result = dir - minus.dir;
|
||||
int16_t result = dir - minus.dir;
|
||||
|
||||
if (result > MODULUS / 2)
|
||||
result -= MODULUS; //get in range
|
||||
else if (result < -MODULUS / 2)
|
||||
result += MODULUS;
|
||||
return (inT8) result;
|
||||
return (int8_t) result;
|
||||
}
|
||||
DIR128 operator+ ( //addition
|
||||
const DIR128 & add) const //of itself
|
||||
@ -74,11 +74,11 @@ class DLLSYM DIR128
|
||||
*this = dir + add.dir; //let = do the work
|
||||
return *this;
|
||||
}
|
||||
inT8 get_dir() const { //access function
|
||||
int8_t get_dir() const { //access function
|
||||
return dir;
|
||||
}
|
||||
|
||||
private:
|
||||
inT8 dir; //a direction
|
||||
int8_t dir; //a direction
|
||||
};
|
||||
#endif
|
||||
|
@ -34,11 +34,11 @@ ELISTIZE (BLOCK)
|
||||
*/
|
||||
BLOCK::BLOCK(const char *name, //< filename
|
||||
BOOL8 prop, //< proportional
|
||||
inT16 kern, //< kerning
|
||||
inT16 space, //< spacing
|
||||
inT16 xmin, //< bottom left
|
||||
inT16 ymin, inT16 xmax, //< top right
|
||||
inT16 ymax)
|
||||
int16_t kern, //< kerning
|
||||
int16_t space, //< spacing
|
||||
int16_t xmin, //< bottom left
|
||||
int16_t ymin, int16_t xmax, //< top right
|
||||
int16_t ymax)
|
||||
: PDBLK (xmin, ymin, xmax, ymax),
|
||||
filename(name),
|
||||
re_rotation_(1.0f, 0.0f),
|
||||
|
@ -42,12 +42,12 @@ class BLOCK:public ELIST_LINK, public PDBLK
|
||||
}
|
||||
BLOCK(const char *name, //< filename
|
||||
BOOL8 prop, //< proportional
|
||||
inT16 kern, //< kerning
|
||||
inT16 space, //< spacing
|
||||
inT16 xmin, //< bottom left
|
||||
inT16 ymin,
|
||||
inT16 xmax, //< top right
|
||||
inT16 ymax);
|
||||
int16_t kern, //< kerning
|
||||
int16_t space, //< spacing
|
||||
int16_t xmin, //< bottom left
|
||||
int16_t ymin,
|
||||
int16_t xmax, //< top right
|
||||
int16_t ymax);
|
||||
|
||||
~BLOCK () {
|
||||
}
|
||||
@ -60,20 +60,20 @@ class BLOCK:public ELIST_LINK, public PDBLK
|
||||
* @param ch_pitch pitch if fixed
|
||||
*/
|
||||
void set_stats(BOOL8 prop,
|
||||
inT16 kern,
|
||||
inT16 space,
|
||||
inT16 ch_pitch) {
|
||||
int16_t kern,
|
||||
int16_t space,
|
||||
int16_t ch_pitch) {
|
||||
proportional = prop;
|
||||
kerning = (inT8) kern;
|
||||
kerning = (int8_t) kern;
|
||||
spacing = space;
|
||||
pitch = ch_pitch;
|
||||
}
|
||||
/// set char size
|
||||
void set_xheight(inT32 height) {
|
||||
void set_xheight(int32_t height) {
|
||||
xheight = height;
|
||||
}
|
||||
/// set font class
|
||||
void set_font_class(inT16 font) {
|
||||
void set_font_class(int16_t font) {
|
||||
font_class = font;
|
||||
}
|
||||
/// return proportional
|
||||
@ -87,19 +87,19 @@ class BLOCK:public ELIST_LINK, public PDBLK
|
||||
right_to_left_ = value;
|
||||
}
|
||||
/// return pitch
|
||||
inT32 fixed_pitch() const {
|
||||
int32_t fixed_pitch() const {
|
||||
return pitch;
|
||||
}
|
||||
/// return kerning
|
||||
inT16 kern() const {
|
||||
int16_t kern() const {
|
||||
return kerning;
|
||||
}
|
||||
/// return font class
|
||||
inT16 font() const {
|
||||
int16_t font() const {
|
||||
return font_class;
|
||||
}
|
||||
/// return spacing
|
||||
inT16 space() const {
|
||||
int16_t space() const {
|
||||
return spacing;
|
||||
}
|
||||
/// return filename
|
||||
@ -107,7 +107,7 @@ class BLOCK:public ELIST_LINK, public PDBLK
|
||||
return filename.string ();
|
||||
}
|
||||
/// return xheight
|
||||
inT32 x_height() const {
|
||||
int32_t x_height() const {
|
||||
return xheight;
|
||||
}
|
||||
float cell_over_xheight() const {
|
||||
@ -195,11 +195,11 @@ class BLOCK:public ELIST_LINK, public PDBLK
|
||||
private:
|
||||
BOOL8 proportional; //< proportional
|
||||
bool right_to_left_; //< major script is right to left.
|
||||
inT8 kerning; //< inter blob gap
|
||||
inT16 spacing; //< inter word gap
|
||||
inT16 pitch; //< pitch of non-props
|
||||
inT16 font_class; //< correct font class
|
||||
inT32 xheight; //< height of chars
|
||||
int8_t kerning; //< inter blob gap
|
||||
int16_t spacing; //< inter word gap
|
||||
int16_t pitch; //< pitch of non-props
|
||||
int16_t font_class; //< correct font class
|
||||
int32_t xheight; //< height of chars
|
||||
float cell_over_xheight_; //< Ratio of cell height to xheight.
|
||||
STRING filename; //< name of block
|
||||
ROW_LIST rows; //< rows in block
|
||||
|
@ -33,14 +33,14 @@ ELISTIZE (ROW)
|
||||
* The words are added directly.
|
||||
**********************************************************************/
|
||||
ROW::ROW ( //constructor
|
||||
inT32 spline_size, //no of segments
|
||||
inT32 * xstarts, //segment boundaries
|
||||
int32_t spline_size, //no of segments
|
||||
int32_t * xstarts, //segment boundaries
|
||||
double *coeffs, //coefficients
|
||||
float x_height, //line height
|
||||
float ascenders, //ascender size
|
||||
float descenders, //descender drop
|
||||
inT16 kern, //char gap
|
||||
inT16 space //word gap
|
||||
int16_t kern, //char gap
|
||||
int16_t space //word gap
|
||||
)
|
||||
: baseline(spline_size, xstarts, coeffs),
|
||||
para_(NULL) {
|
||||
@ -65,8 +65,8 @@ inT16 space //word gap
|
||||
|
||||
ROW::ROW( //constructor
|
||||
TO_ROW *to_row, //source row
|
||||
inT16 kern, //char gap
|
||||
inT16 space //word gap
|
||||
int16_t kern, //char gap
|
||||
int16_t space //word gap
|
||||
) : para_(NULL) {
|
||||
kerning = kern; //just store stuff
|
||||
spacing = space;
|
||||
@ -101,8 +101,8 @@ TBOX ROW::restricted_bounding_box(bool upper_dots, bool lower_dots) const {
|
||||
void ROW::recalc_bounding_box() { //recalculate BB
|
||||
WERD *word; //current word
|
||||
WERD_IT it = &words; //words of ROW
|
||||
inT16 left; //of word
|
||||
inT16 prev_left; //old left
|
||||
int16_t left; //of word
|
||||
int16_t prev_left; //old left
|
||||
|
||||
if (!it.empty ()) {
|
||||
word = it.data ();
|
||||
|
@ -36,18 +36,18 @@ class ROW:public ELIST_LINK
|
||||
ROW() {
|
||||
} //empty constructor
|
||||
ROW( //constructor
|
||||
inT32 spline_size, //no of segments
|
||||
inT32 *xstarts, //segment boundaries
|
||||
int32_t spline_size, //no of segments
|
||||
int32_t *xstarts, //segment boundaries
|
||||
double *coeffs, //coefficients //ascender size
|
||||
float x_height,
|
||||
float ascenders,
|
||||
float descenders, //descender size
|
||||
inT16 kern, //char gap
|
||||
inT16 space); //word gap
|
||||
int16_t kern, //char gap
|
||||
int16_t space); //word gap
|
||||
ROW( //constructor
|
||||
TO_ROW *row, //textord row
|
||||
inT16 kern, //char gap
|
||||
inT16 space); //word gap
|
||||
int16_t kern, //char gap
|
||||
int16_t space); //word gap
|
||||
|
||||
WERD_LIST *word_list() { //get words
|
||||
return &words;
|
||||
@ -64,7 +64,7 @@ class ROW:public ELIST_LINK
|
||||
void set_x_height(float new_xheight) { // set x height
|
||||
xheight = new_xheight;
|
||||
}
|
||||
inT32 kern() const { //return kerning
|
||||
int32_t kern() const { //return kerning
|
||||
return kerning;
|
||||
}
|
||||
float body_size() const { //return body size
|
||||
@ -73,7 +73,7 @@ class ROW:public ELIST_LINK
|
||||
void set_body_size(float new_size) { // set body size
|
||||
bodysize = new_size;
|
||||
}
|
||||
inT32 space() const { //return spacing
|
||||
int32_t space() const { //return spacing
|
||||
return spacing;
|
||||
}
|
||||
float ascenders() const { //return size
|
||||
@ -89,16 +89,16 @@ class ROW:public ELIST_LINK
|
||||
// lower noise/diacritic elements.
|
||||
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const;
|
||||
|
||||
void set_lmargin(inT16 lmargin) {
|
||||
void set_lmargin(int16_t lmargin) {
|
||||
lmargin_ = lmargin;
|
||||
}
|
||||
void set_rmargin(inT16 rmargin) {
|
||||
void set_rmargin(int16_t rmargin) {
|
||||
rmargin_ = rmargin;
|
||||
}
|
||||
inT16 lmargin() const {
|
||||
int16_t lmargin() const {
|
||||
return lmargin_;
|
||||
}
|
||||
inT16 rmargin() const {
|
||||
int16_t rmargin() const {
|
||||
return rmargin_;
|
||||
}
|
||||
|
||||
@ -141,8 +141,8 @@ class ROW:public ELIST_LINK
|
||||
ROW& operator= (const ROW & source);
|
||||
|
||||
private:
|
||||
inT32 kerning; //inter char gap
|
||||
inT32 spacing; //inter word gap
|
||||
int32_t kerning; //inter char gap
|
||||
int32_t spacing; //inter word gap
|
||||
TBOX bound_box; //bounding box
|
||||
float xheight; //height of line
|
||||
float ascrise; //size of ascenders
|
||||
@ -154,8 +154,8 @@ class ROW:public ELIST_LINK
|
||||
|
||||
// These get set after blocks have been determined.
|
||||
bool has_drop_cap_;
|
||||
inT16 lmargin_; // Distance to left polyblock margin.
|
||||
inT16 rmargin_; // Distance to right polyblock margin.
|
||||
int16_t lmargin_; // Distance to left polyblock margin.
|
||||
int16_t rmargin_; // Distance to right polyblock margin.
|
||||
|
||||
// This gets set during paragraph analysis.
|
||||
PARA *para_; // Paragraph of which this row is part.
|
||||
|
@ -896,8 +896,8 @@ void WERD_RES::FakeWordFromRatings(PermuterType permuter) {
|
||||
word_choice->set_permuter(permuter);
|
||||
for (int b = 0; b < num_blobs; ++b) {
|
||||
UNICHAR_ID unichar_id = UNICHAR_SPACE;
|
||||
float rating = MAX_INT32;
|
||||
float certainty = -MAX_INT32;
|
||||
float rating = INT32_MAX;
|
||||
float certainty = -INT32_MAX;
|
||||
BLOB_CHOICE_LIST* choices = ratings->get(b, b);
|
||||
if (choices != NULL && !choices->empty()) {
|
||||
BLOB_CHOICE_IT bc_it(choices);
|
||||
@ -1307,7 +1307,7 @@ static void ComputeBlobEnds(const WERD_RES& word, C_BLOB_LIST* next_word_blobs,
|
||||
}
|
||||
// This blob_box is crap, so for now we are only looking for the
|
||||
// boundaries between them.
|
||||
int blob_end = MAX_INT32;
|
||||
int blob_end = INT32_MAX;
|
||||
if (!blob_it.at_first() || next_word_blobs != NULL) {
|
||||
if (blob_it.at_first())
|
||||
blob_it.set_to_list(next_word_blobs);
|
||||
@ -1673,8 +1673,8 @@ WERD_RES *PAGE_RES_IT::forward_block() {
|
||||
}
|
||||
|
||||
void PAGE_RES_IT::rej_stat_word() {
|
||||
inT16 chars_in_word;
|
||||
inT16 rejects_in_word = 0;
|
||||
int16_t chars_in_word;
|
||||
int16_t rejects_in_word = 0;
|
||||
|
||||
chars_in_word = word_res->reject_map.length ();
|
||||
page_res->char_count += chars_in_word;
|
||||
|
@ -57,8 +57,8 @@ ELISTIZEH (WERD_RES)
|
||||
*************************************************************************/
|
||||
class PAGE_RES { // page result
|
||||
public:
|
||||
inT32 char_count;
|
||||
inT32 rej_count;
|
||||
int32_t char_count;
|
||||
int32_t rej_count;
|
||||
BLOCK_RES_LIST block_res_list;
|
||||
BOOL8 rejected;
|
||||
// Updated every time PAGE_RES_IT iterating on this PAGE_RES moves to
|
||||
@ -97,10 +97,10 @@ class PAGE_RES { // page result
|
||||
class BLOCK_RES:public ELIST_LINK {
|
||||
public:
|
||||
BLOCK * block; // real block
|
||||
inT32 char_count; // chars in block
|
||||
inT32 rej_count; // rejected chars
|
||||
inT16 font_class; //
|
||||
inT16 row_count;
|
||||
int32_t char_count; // chars in block
|
||||
int32_t rej_count; // rejected chars
|
||||
int16_t font_class; //
|
||||
int16_t row_count;
|
||||
float x_height;
|
||||
BOOL8 font_assigned; // block already
|
||||
// processed
|
||||
@ -125,9 +125,9 @@ class BLOCK_RES:public ELIST_LINK {
|
||||
class ROW_RES:public ELIST_LINK {
|
||||
public:
|
||||
ROW * row; // real row
|
||||
inT32 char_count; // chars in block
|
||||
inT32 rej_count; // rejected chars
|
||||
inT32 whole_word_rej_count; // rejs in total rej wds
|
||||
int32_t char_count; // chars in block
|
||||
int32_t rej_count; // rejected chars
|
||||
int32_t whole_word_rej_count; // rejs in total rej wds
|
||||
WERD_RES_LIST word_res_list;
|
||||
|
||||
ROW_RES() {
|
||||
@ -282,13 +282,13 @@ class WERD_RES : public ELIST_LINK {
|
||||
BOOL8 done; // ready for output?
|
||||
bool small_caps; // word appears to be small caps
|
||||
bool odd_size; // word is bigger than line or leader dots.
|
||||
inT8 italic;
|
||||
inT8 bold;
|
||||
int8_t italic;
|
||||
int8_t bold;
|
||||
// The fontinfos are pointers to data owned by the classifier.
|
||||
const FontInfo* fontinfo;
|
||||
const FontInfo* fontinfo2;
|
||||
inT8 fontinfo_id_count; // number of votes
|
||||
inT8 fontinfo_id2_count; // number of votes
|
||||
int8_t fontinfo_id_count; // number of votes
|
||||
int8_t fontinfo_id2_count; // number of votes
|
||||
BOOL8 guessed_x_ht;
|
||||
BOOL8 guessed_caps_ht;
|
||||
CRUNCH_MODE unlv_crunch_mode;
|
||||
|
@ -37,9 +37,9 @@ CLISTIZE (PDBLK)
|
||||
* Constructor for a simple rectangular block.
|
||||
**********************************************************************/
|
||||
PDBLK::PDBLK ( //rectangular block
|
||||
inT16 xmin, //bottom left
|
||||
inT16 ymin, inT16 xmax, //top right
|
||||
inT16 ymax): box (ICOORD (xmin, ymin), ICOORD (xmax, ymax)) {
|
||||
int16_t xmin, //bottom left
|
||||
int16_t ymin, int16_t xmax, //top right
|
||||
int16_t ymax): box (ICOORD (xmin, ymin), ICOORD (xmax, ymax)) {
|
||||
//boundaries
|
||||
ICOORDELT_IT left_it = &leftside;
|
||||
ICOORDELT_IT right_it = &rightside;
|
||||
@ -177,7 +177,7 @@ Pix* PDBLK::render_mask(const FCOORD& rerotation, TBOX* mask_box) {
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
void PDBLK::plot( //draw outline
|
||||
ScrollView* window, //window to draw in
|
||||
inT32 serial, //serial number
|
||||
int32_t serial, //serial number
|
||||
ScrollView::Color colour //colour to draw in
|
||||
) {
|
||||
ICOORD startpt; //start of outline
|
||||
@ -342,9 +342,9 @@ void BLOCK_RECT_IT::forward() { //next rectangle
|
||||
* Get the the start and width of a line in the block.
|
||||
**********************************************************************/
|
||||
|
||||
inT16 BLOCK_LINE_IT::get_line( //get a line
|
||||
inT16 y, //line to get
|
||||
inT16 &xext //output extent
|
||||
int16_t BLOCK_LINE_IT::get_line( //get a line
|
||||
int16_t y, //line to get
|
||||
int16_t &xext //output extent
|
||||
) {
|
||||
ICOORD bleft; //bounding box
|
||||
ICOORD tright; //of block & rect
|
||||
|
@ -39,10 +39,10 @@ class PDBLK {
|
||||
index_ = 0;
|
||||
}
|
||||
/// simple constructor
|
||||
PDBLK(inT16 xmin, //< bottom left
|
||||
inT16 ymin,
|
||||
inT16 xmax, //< top right
|
||||
inT16 ymax);
|
||||
PDBLK(int16_t xmin, //< bottom left
|
||||
int16_t ymin,
|
||||
int16_t xmax, //< top right
|
||||
int16_t ymax);
|
||||
|
||||
/// set vertex lists
|
||||
///@param left list of left vertices
|
||||
@ -84,7 +84,7 @@ class PDBLK {
|
||||
///@param window window to draw in
|
||||
///@param serial serial number
|
||||
///@param colour colour to draw in
|
||||
void plot(ScrollView *window, inT32 serial, ScrollView::Color colour);
|
||||
void plot(ScrollView *window, int32_t serial, ScrollView::Color colour);
|
||||
#endif // GRAPHICS_DISABLED
|
||||
|
||||
/// assignment
|
||||
@ -133,8 +133,8 @@ class DLLSYM BLOCK_RECT_IT //rectangle iterator
|
||||
}
|
||||
|
||||
private:
|
||||
inT16 ymin; //< bottom of rectangle
|
||||
inT16 ymax; //< top of rectangle
|
||||
int16_t ymin; //< bottom of rectangle
|
||||
int16_t ymax; //< top of rectangle
|
||||
PDBLK *block; //< block to iterate
|
||||
ICOORDELT_IT left_it; //< boundary iterators
|
||||
ICOORDELT_IT right_it;
|
||||
@ -162,8 +162,8 @@ class DLLSYM BLOCK_LINE_IT
|
||||
///get a line
|
||||
///@param y line to get
|
||||
///@param xext output extent
|
||||
inT16 get_line(inT16 y,
|
||||
inT16 &xext);
|
||||
int16_t get_line(int16_t y,
|
||||
int16_t &xext);
|
||||
|
||||
private:
|
||||
PDBLK * block; //< block to iterate
|
||||
|
@ -44,8 +44,8 @@ void ICOORD::set_with_shrink(int x, int y) {
|
||||
// Fit the vector into an ICOORD, which is 16 bit.
|
||||
int factor = 1;
|
||||
int max_extent = MAX(abs(x), abs(y));
|
||||
if (max_extent > MAX_INT16)
|
||||
factor = max_extent / MAX_INT16 + 1;
|
||||
if (max_extent > INT16_MAX)
|
||||
factor = max_extent / INT16_MAX + 1;
|
||||
xcoord = x / factor;
|
||||
ycoord = y / factor;
|
||||
}
|
||||
@ -108,11 +108,11 @@ void ICOORD::setup_render(ICOORD* major_step, ICOORD* minor_step,
|
||||
|
||||
// Returns the standard feature direction corresponding to this.
|
||||
// See binary_angle_plus_pi below for a description of the direction.
|
||||
uinT8 FCOORD::to_direction() const {
|
||||
uint8_t FCOORD::to_direction() const {
|
||||
return binary_angle_plus_pi(angle());
|
||||
}
|
||||
// Sets this with a unit vector in the given standard feature direction.
|
||||
void FCOORD::from_direction(uinT8 direction) {
|
||||
void FCOORD::from_direction(uint8_t direction) {
|
||||
double radians = angle_from_direction(direction);
|
||||
xcoord = cos(radians);
|
||||
ycoord = sin(radians);
|
||||
@ -121,12 +121,12 @@ void FCOORD::from_direction(uinT8 direction) {
|
||||
// Converts an angle in radians (from ICOORD::angle or FCOORD::angle) to a
|
||||
// standard feature direction as an unsigned angle in 256ths of a circle
|
||||
// measured anticlockwise from (-1, 0).
|
||||
uinT8 FCOORD::binary_angle_plus_pi(double radians) {
|
||||
uint8_t FCOORD::binary_angle_plus_pi(double radians) {
|
||||
return Modulo(IntCastRounded((radians + M_PI) * 128.0 / M_PI), 256);
|
||||
}
|
||||
// Inverse of binary_angle_plus_pi returns an angle in radians for the
|
||||
// given standard feature direction.
|
||||
double FCOORD::angle_from_direction(uinT8 direction) {
|
||||
double FCOORD::angle_from_direction(uint8_t direction) {
|
||||
return direction * M_PI / 128.0 - M_PI;
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ class ICOORD
|
||||
///constructor
|
||||
///@param xin x value
|
||||
///@param yin y value
|
||||
ICOORD(inT16 xin,
|
||||
inT16 yin) {
|
||||
ICOORD(int16_t xin,
|
||||
int16_t yin) {
|
||||
xcoord = xin;
|
||||
ycoord = yin;
|
||||
}
|
||||
@ -49,20 +49,20 @@ class ICOORD
|
||||
}
|
||||
|
||||
///access function
|
||||
inT16 x() const {
|
||||
int16_t x() const {
|
||||
return xcoord;
|
||||
}
|
||||
///access_function
|
||||
inT16 y() const {
|
||||
int16_t y() const {
|
||||
return ycoord;
|
||||
}
|
||||
|
||||
///rewrite function
|
||||
void set_x(inT16 xin) {
|
||||
void set_x(int16_t xin) {
|
||||
xcoord = xin; //write new value
|
||||
}
|
||||
///rewrite function
|
||||
void set_y(inT16 yin) { //value to set
|
||||
void set_y(int16_t yin) { //value to set
|
||||
ycoord = yin;
|
||||
}
|
||||
|
||||
@ -119,22 +119,22 @@ class ICOORD
|
||||
///subtract
|
||||
friend ICOORD & operator-= (ICOORD &, const ICOORD &);
|
||||
///scalar product
|
||||
friend inT32 operator% (const ICOORD &, const ICOORD &);
|
||||
friend int32_t operator% (const ICOORD &, const ICOORD &);
|
||||
///cross product
|
||||
friend inT32 operator *(const ICOORD &,
|
||||
friend int32_t operator *(const ICOORD &,
|
||||
const ICOORD &);
|
||||
///multiply
|
||||
friend ICOORD operator *(const ICOORD &,
|
||||
inT16);
|
||||
int16_t);
|
||||
///multiply
|
||||
friend ICOORD operator *(inT16,
|
||||
friend ICOORD operator *(int16_t,
|
||||
const ICOORD &);
|
||||
///multiply
|
||||
friend ICOORD & operator*= (ICOORD &, inT16);
|
||||
friend ICOORD & operator*= (ICOORD &, int16_t);
|
||||
///divide
|
||||
friend ICOORD operator/ (const ICOORD &, inT16);
|
||||
friend ICOORD operator/ (const ICOORD &, int16_t);
|
||||
///divide
|
||||
friend ICOORD & operator/= (ICOORD &, inT16);
|
||||
friend ICOORD & operator/= (ICOORD &, int16_t);
|
||||
///rotate
|
||||
///@param vec by vector
|
||||
void rotate(const FCOORD& vec);
|
||||
@ -154,8 +154,8 @@ class ICOORD
|
||||
bool DeSerialize(bool swap, FILE* fp);
|
||||
|
||||
protected:
|
||||
inT16 xcoord; //< x value
|
||||
inT16 ycoord; //< y value
|
||||
int16_t xcoord; //< x value
|
||||
int16_t ycoord; //< y value
|
||||
};
|
||||
|
||||
class DLLSYM ICOORDELT:public ELIST_LINK, public ICOORD
|
||||
@ -171,8 +171,8 @@ class DLLSYM ICOORDELT:public ELIST_LINK, public ICOORD
|
||||
///constructor
|
||||
///@param xin x value
|
||||
///@param yin y value
|
||||
ICOORDELT(inT16 xin,
|
||||
inT16 yin) {
|
||||
ICOORDELT(int16_t xin,
|
||||
int16_t yin) {
|
||||
xcoord = xin;
|
||||
ycoord = yin;
|
||||
}
|
||||
@ -251,17 +251,17 @@ class DLLSYM FCOORD
|
||||
}
|
||||
// Returns the standard feature direction corresponding to this.
|
||||
// See binary_angle_plus_pi below for a description of the direction.
|
||||
uinT8 to_direction() const;
|
||||
uint8_t to_direction() const;
|
||||
// Sets this with a unit vector in the given standard feature direction.
|
||||
void from_direction(uinT8 direction);
|
||||
void from_direction(uint8_t direction);
|
||||
|
||||
// Converts an angle in radians (from ICOORD::angle or FCOORD::angle) to a
|
||||
// standard feature direction as an unsigned angle in 256ths of a circle
|
||||
// measured anticlockwise from (-1, 0).
|
||||
static uinT8 binary_angle_plus_pi(double angle);
|
||||
static uint8_t binary_angle_plus_pi(double angle);
|
||||
// Inverse of binary_angle_plus_pi returns an angle in radians for the
|
||||
// given standard feature direction.
|
||||
static double angle_from_direction(uinT8 direction);
|
||||
static double angle_from_direction(uint8_t direction);
|
||||
// Returns the point on the given line nearest to this, ie the point such
|
||||
// that the vector point->this is perpendicular to the line.
|
||||
// The line is defined as a line_point and a dir_vector for its direction.
|
||||
|
@ -59,7 +59,7 @@ const int par2 = 6750 / (approx_dist * approx_dist);
|
||||
|
||||
TESSLINE* ApproximateOutline(bool allow_detailed_fx, C_OUTLINE* c_outline) {
|
||||
TBOX loop_box; // bounding box
|
||||
inT32 area; // loop area
|
||||
int32_t area; // loop area
|
||||
EDGEPT stack_edgepts[FASTEDGELENGTH]; // converted path
|
||||
EDGEPT* edgepts = stack_edgepts;
|
||||
|
||||
@ -116,15 +116,15 @@ edgesteps_to_edgepts ( //convert outline
|
||||
C_OUTLINE * c_outline, //input
|
||||
EDGEPT edgepts[] //output is array
|
||||
) {
|
||||
inT32 length; //steps in path
|
||||
int32_t length; //steps in path
|
||||
ICOORD pos; //current coords
|
||||
inT32 stepindex; //current step
|
||||
inT32 stepinc; //increment
|
||||
inT32 epindex; //current EDGEPT
|
||||
inT32 count; //repeated steps
|
||||
int32_t stepindex; //current step
|
||||
int32_t stepinc; //increment
|
||||
int32_t epindex; //current EDGEPT
|
||||
int32_t count; //repeated steps
|
||||
ICOORD vec; //for this 8 step
|
||||
ICOORD prev_vec;
|
||||
inT8 epdir; //of this step
|
||||
int8_t epdir; //of this step
|
||||
DIR128 prevdir; //prvious dir
|
||||
DIR128 dir; //of this step
|
||||
|
||||
@ -556,7 +556,7 @@ void cutline( //recursive refine
|
||||
perp = LENGTH (vecsum);
|
||||
ASSERT_HOST (perp != 0);
|
||||
|
||||
if (maxperp < 256 * MAX_INT16) {
|
||||
if (maxperp < 256 * INT16_MAX) {
|
||||
maxperp <<= 8;
|
||||
maxperp /= perp; /*true max perp */
|
||||
}
|
||||
@ -564,7 +564,7 @@ void cutline( //recursive refine
|
||||
maxperp /= perp;
|
||||
maxperp <<= 8; /*avoid overflow */
|
||||
}
|
||||
if (squaresum < 256 * MAX_INT16)
|
||||
if (squaresum < 256 * INT16_MAX)
|
||||
/*mean squared perp */
|
||||
perp = (squaresum << 8) / (perp * ptcount);
|
||||
else
|
||||
|
@ -30,7 +30,7 @@
|
||||
#endif
|
||||
|
||||
#define PBLOCK_LABEL_SIZE 150
|
||||
#define INTERSECTING MAX_INT16
|
||||
#define INTERSECTING INT16_MAX
|
||||
|
||||
int lessthan(const void *first, const void *second);
|
||||
|
||||
@ -99,12 +99,12 @@ void POLY_BLOCK::compute_bb() { //constructor
|
||||
* @param point point to wind around
|
||||
*/
|
||||
|
||||
inT16 POLY_BLOCK::winding_number(const ICOORD &point) {
|
||||
inT16 count; //winding count
|
||||
int16_t POLY_BLOCK::winding_number(const ICOORD &point) {
|
||||
int16_t count; //winding count
|
||||
ICOORD pt; //current point
|
||||
ICOORD vec; //point to current point
|
||||
ICOORD vvec; //current point to next point
|
||||
inT32 cross; //cross product
|
||||
int32_t cross; //cross product
|
||||
ICOORDELT_IT it = &vertices; //iterator
|
||||
|
||||
count = 0;
|
||||
@ -138,7 +138,7 @@ inT16 POLY_BLOCK::winding_number(const ICOORD &point) {
|
||||
|
||||
/// @return true if other is inside this.
|
||||
bool POLY_BLOCK::contains(POLY_BLOCK *other) {
|
||||
inT16 count; // winding count
|
||||
int16_t count; // winding count
|
||||
ICOORDELT_IT it = &vertices; // iterator
|
||||
ICOORD vertex;
|
||||
|
||||
@ -193,8 +193,8 @@ void POLY_BLOCK::rotate(FCOORD rotation) {
|
||||
pos.set_x (pt->x ());
|
||||
pos.set_y (pt->y ());
|
||||
pos.rotate (rotation);
|
||||
pt->set_x ((inT16) (floor (pos.x () + 0.5)));
|
||||
pt->set_y ((inT16) (floor (pos.y () + 0.5)));
|
||||
pt->set_x ((int16_t) (floor (pos.x () + 0.5)));
|
||||
pt->set_y ((int16_t) (floor (pos.y () + 0.5)));
|
||||
pts.forward ();
|
||||
}
|
||||
while (!pts.at_first ());
|
||||
@ -243,7 +243,7 @@ void POLY_BLOCK::move(ICOORD shift) {
|
||||
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
void POLY_BLOCK::plot(ScrollView* window, inT32 num) {
|
||||
void POLY_BLOCK::plot(ScrollView* window, int32_t num) {
|
||||
ICOORDELT_IT v = &vertices;
|
||||
|
||||
window->Pen(ColorForPolyBlockType(type));
|
||||
@ -271,8 +271,8 @@ void POLY_BLOCK::plot(ScrollView* window, inT32 num) {
|
||||
|
||||
|
||||
void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
|
||||
inT16 y;
|
||||
inT16 width;
|
||||
int16_t y;
|
||||
int16_t width;
|
||||
PB_LINE_IT *lines;
|
||||
ICOORDELT_IT s_it;
|
||||
|
||||
@ -303,7 +303,7 @@ void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
|
||||
|
||||
/// @return true if the polygons of other and this overlap.
|
||||
bool POLY_BLOCK::overlap(POLY_BLOCK *other) {
|
||||
inT16 count; // winding count
|
||||
int16_t count; // winding count
|
||||
ICOORDELT_IT it = &vertices; // iterator
|
||||
ICOORD vertex;
|
||||
|
||||
@ -341,7 +341,7 @@ bool POLY_BLOCK::overlap(POLY_BLOCK *other) {
|
||||
}
|
||||
|
||||
|
||||
ICOORDELT_LIST *PB_LINE_IT::get_line(inT16 y) {
|
||||
ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) {
|
||||
ICOORDELT_IT v, r;
|
||||
ICOORDELT_LIST *result;
|
||||
ICOORDELT *x, *current, *previous;
|
||||
@ -361,7 +361,7 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(inT16 y) {
|
||||
(current->x () - previous->x ()) * (fy -
|
||||
previous->y ()) /
|
||||
(current->y () - previous->y ()));
|
||||
x = new ICOORDELT ((inT16) fx, 0);
|
||||
x = new ICOORDELT ((int16_t) fx, 0);
|
||||
r.add_to_end (x);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class DLLSYM POLY_BLOCK {
|
||||
// Move by adding shift to all coordinates.
|
||||
void move(ICOORD shift);
|
||||
|
||||
void plot(ScrollView* window, inT32 num);
|
||||
void plot(ScrollView* window, int32_t num);
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
void fill(ScrollView* window, ScrollView::Color colour);
|
||||
@ -76,7 +76,7 @@ class DLLSYM POLY_BLOCK {
|
||||
// Returns the winding number of this around the test_pt.
|
||||
// Positive for anticlockwise, negative for clockwise, and zero for
|
||||
// test_pt outside this.
|
||||
inT16 winding_number(const ICOORD &test_pt);
|
||||
int16_t winding_number(const ICOORD &test_pt);
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
// Static utility functions to handle the PolyBlockType.
|
||||
@ -105,7 +105,7 @@ class DLLSYM PB_LINE_IT {
|
||||
// Each element of the returned list is the start (x) and extent(y) of
|
||||
// a run inside the region.
|
||||
// Delete the returned list after use.
|
||||
ICOORDELT_LIST *get_line(inT16 y);
|
||||
ICOORDELT_LIST *get_line(int16_t y);
|
||||
|
||||
private:
|
||||
POLY_BLOCK * block;
|
||||
|
@ -36,7 +36,7 @@ class QLSQ
|
||||
void remove( //delete element
|
||||
double x, //coords to delete
|
||||
double y);
|
||||
inT32 count() { //no of elements
|
||||
int32_t count() { //no of elements
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class QLSQ
|
||||
}
|
||||
|
||||
private:
|
||||
inT32 n; //no of elements
|
||||
int32_t n; //no of elements
|
||||
double a, b, c; //result
|
||||
double sigx; //sum of x
|
||||
double sigy; //sum of y
|
||||
|
@ -48,8 +48,8 @@ class QUAD_COEFFS
|
||||
y - q = ax^2 - 2apx + ap^2 + bx - bp + c
|
||||
y = ax^2 + (b - 2ap)x + (c - bp + ap^2 + q)
|
||||
************************************************************/
|
||||
inT16 p = vec.x ();
|
||||
inT16 q = vec.y ();
|
||||
int16_t p = vec.x ();
|
||||
int16_t q = vec.y ();
|
||||
|
||||
c = (float) (c - b * p + a * p * p + q);
|
||||
b = (float) (b - 2 * a * p);
|
||||
|
@ -36,14 +36,14 @@
|
||||
**********************************************************************/
|
||||
|
||||
QSPLINE::QSPLINE( //constructor
|
||||
inT32 count, //no of segments
|
||||
inT32 *xstarts, //start coords
|
||||
int32_t count, //no of segments
|
||||
int32_t *xstarts, //start coords
|
||||
double *coeffs //coefficients
|
||||
) {
|
||||
inT32 index; //segment index
|
||||
int32_t index; //segment index
|
||||
|
||||
//get memory
|
||||
xcoords = (inT32 *) alloc_mem ((count + 1) * sizeof (inT32));
|
||||
xcoords = (int32_t *) alloc_mem ((count + 1) * sizeof (int32_t));
|
||||
quadratics = (QUAD_COEFFS *) alloc_mem (count * sizeof (QUAD_COEFFS));
|
||||
segments = count;
|
||||
for (index = 0; index < segments; index++) {
|
||||
@ -73,14 +73,14 @@ int degree //fit required
|
||||
) {
|
||||
int pointindex; /*no along text line */
|
||||
int segment; /*segment no */
|
||||
inT32 *ptcounts; //no in each segment
|
||||
int32_t *ptcounts; //no in each segment
|
||||
QLSQ qlsq; /*accumulator */
|
||||
|
||||
segments = segcount;
|
||||
xcoords = (inT32 *) alloc_mem ((segcount + 1) * sizeof (inT32));
|
||||
ptcounts = (inT32 *) alloc_mem ((segcount + 1) * sizeof (inT32));
|
||||
xcoords = (int32_t *) alloc_mem ((segcount + 1) * sizeof (int32_t));
|
||||
ptcounts = (int32_t *) alloc_mem ((segcount + 1) * sizeof (int32_t));
|
||||
quadratics = (QUAD_COEFFS *) alloc_mem (segcount * sizeof (QUAD_COEFFS));
|
||||
memmove (xcoords, xstarts, (segcount + 1) * sizeof (inT32));
|
||||
memmove (xcoords, xstarts, (segcount + 1) * sizeof (int32_t));
|
||||
ptcounts[0] = 0; /*none in any yet */
|
||||
for (segment = 0, pointindex = 0; pointindex < pointcount; pointindex++) {
|
||||
while (segment < segcount && xpts[pointindex] >= xstarts[segment]) {
|
||||
@ -175,9 +175,9 @@ const QSPLINE & source) {
|
||||
free_mem(quadratics);
|
||||
|
||||
segments = source.segments;
|
||||
xcoords = (inT32 *) alloc_mem ((segments + 1) * sizeof (inT32));
|
||||
xcoords = (int32_t *) alloc_mem ((segments + 1) * sizeof (int32_t));
|
||||
quadratics = (QUAD_COEFFS *) alloc_mem (segments * sizeof (QUAD_COEFFS));
|
||||
memmove (xcoords, source.xcoords, (segments + 1) * sizeof (inT32));
|
||||
memmove (xcoords, source.xcoords, (segments + 1) * sizeof (int32_t));
|
||||
memmove (quadratics, source.quadratics, segments * sizeof (QUAD_COEFFS));
|
||||
return *this;
|
||||
}
|
||||
@ -217,7 +217,7 @@ double QSPLINE::step( //find step functions
|
||||
double QSPLINE::y( //evaluate
|
||||
double x //coord to evaluate at
|
||||
) const {
|
||||
inT32 index; //segment index
|
||||
int32_t index; //segment index
|
||||
|
||||
index = spline_index (x);
|
||||
return quadratics[index].y (x);//in correct segment
|
||||
@ -230,12 +230,12 @@ double QSPLINE::y( //evaluate
|
||||
* Return the index to the largest xcoord not greater than x.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 QSPLINE::spline_index( //evaluate
|
||||
int32_t QSPLINE::spline_index( //evaluate
|
||||
double x //coord to evaluate at
|
||||
) const {
|
||||
inT32 index; //segment index
|
||||
inT32 bottom; //bottom of range
|
||||
inT32 top; //top of range
|
||||
int32_t index; //segment index
|
||||
int32_t bottom; //bottom of range
|
||||
int32_t top; //top of range
|
||||
|
||||
bottom = 0;
|
||||
top = segments;
|
||||
@ -259,8 +259,8 @@ inT32 QSPLINE::spline_index( //evaluate
|
||||
void QSPLINE::move( // reposition spline
|
||||
ICOORD vec // by vector
|
||||
) {
|
||||
inT32 segment; //index of segment
|
||||
inT16 x_shift = vec.x ();
|
||||
int32_t segment; //index of segment
|
||||
int16_t x_shift = vec.x ();
|
||||
|
||||
for (segment = 0; segment < segments; segment++) {
|
||||
xcoords[segment] += x_shift;
|
||||
@ -348,7 +348,7 @@ void QSPLINE::extrapolate( //linear extrapolation
|
||||
segments = dest_segment;
|
||||
free_mem(xcoords);
|
||||
free_mem(quadratics);
|
||||
xcoords = (inT32 *) xstarts;
|
||||
xcoords = (int32_t *) xstarts;
|
||||
quadratics = quads;
|
||||
}
|
||||
|
||||
@ -364,8 +364,8 @@ void QSPLINE::plot( //draw it
|
||||
ScrollView* window, //window to draw in
|
||||
ScrollView::Color colour //colour to draw in
|
||||
) const {
|
||||
inT32 segment; //index of segment
|
||||
inT16 step; //index of poly piece
|
||||
int32_t segment; //index of segment
|
||||
int16_t step; //index of poly piece
|
||||
double increment; //x increment
|
||||
double x; //x coord
|
||||
|
||||
@ -391,8 +391,8 @@ void QSPLINE::plot(Pix *pix) const {
|
||||
return;
|
||||
}
|
||||
|
||||
inT32 segment; // Index of segment
|
||||
inT16 step; // Index of poly piece
|
||||
int32_t segment; // Index of segment
|
||||
int16_t step; // Index of poly piece
|
||||
double increment; // x increment
|
||||
double x; // x coord
|
||||
double height = static_cast<double>(pixGetHeight(pix));
|
||||
|
@ -48,8 +48,8 @@ class QSPLINE
|
||||
QSPLINE( //copy constructor
|
||||
const QSPLINE &src);
|
||||
QSPLINE( //constructor
|
||||
inT32 count, //number of segments
|
||||
inT32 *xstarts, //segment starts
|
||||
int32_t count, //number of segments
|
||||
int32_t *xstarts, //segment starts
|
||||
double *coeffs); //coefficients
|
||||
~QSPLINE (); //destructor
|
||||
QSPLINE ( //least squares fit
|
||||
@ -90,10 +90,10 @@ class QSPLINE
|
||||
|
||||
private:
|
||||
|
||||
inT32 spline_index( //binary search
|
||||
int32_t spline_index( //binary search
|
||||
double x) const; //for x
|
||||
inT32 segments; //no of segments
|
||||
inT32 *xcoords; //no of coords
|
||||
int32_t segments; //no of segments
|
||||
int32_t *xcoords; //no of coords
|
||||
QUAD_COEFFS *quadratics; //spline pieces
|
||||
};
|
||||
#endif
|
||||
|
@ -172,7 +172,7 @@ BLOB_CHOICE* FindMatchingChoice(UNICHAR_ID char_id,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *WERD_CHOICE::permuter_name(uinT8 permuter) {
|
||||
const char *WERD_CHOICE::permuter_name(uint8_t permuter) {
|
||||
return kPermuterTypeNames[permuter];
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ void WERD_CHOICE::init(const char *src_string,
|
||||
const char *src_lengths,
|
||||
float src_rating,
|
||||
float src_certainty,
|
||||
uinT8 src_permuter) {
|
||||
uint8_t src_permuter) {
|
||||
int src_string_len = strlen(src_string);
|
||||
if (src_string_len == 0) {
|
||||
this->init(8);
|
||||
|
@ -82,10 +82,10 @@ class BLOB_CHOICE: public ELIST_LINK
|
||||
float certainty() const {
|
||||
return certainty_;
|
||||
}
|
||||
inT16 fontinfo_id() const {
|
||||
int16_t fontinfo_id() const {
|
||||
return fontinfo_id_;
|
||||
}
|
||||
inT16 fontinfo_id2() const {
|
||||
int16_t fontinfo_id2() const {
|
||||
return fontinfo_id2_;
|
||||
}
|
||||
const GenericVector<tesseract::ScoredFont>& fonts() const {
|
||||
@ -114,10 +114,10 @@ class BLOB_CHOICE: public ELIST_LINK
|
||||
const MATRIX_COORD& matrix_cell() {
|
||||
return matrix_cell_;
|
||||
}
|
||||
inT16 xgap_before() const {
|
||||
int16_t xgap_before() const {
|
||||
return xgap_before_;
|
||||
}
|
||||
inT16 xgap_after() const {
|
||||
int16_t xgap_after() const {
|
||||
return xgap_after_;
|
||||
}
|
||||
float min_xheight() const {
|
||||
@ -157,10 +157,10 @@ class BLOB_CHOICE: public ELIST_LINK
|
||||
matrix_cell_.col = col;
|
||||
matrix_cell_.row = row;
|
||||
}
|
||||
void set_xgap_before(inT16 gap) {
|
||||
void set_xgap_before(int16_t gap) {
|
||||
xgap_before_ = gap;
|
||||
}
|
||||
void set_xgap_after(inT16 gap) {
|
||||
void set_xgap_after(int16_t gap) {
|
||||
xgap_after_ = gap;
|
||||
}
|
||||
void set_classifier(BlobChoiceClassifier classifier) {
|
||||
@ -199,8 +199,8 @@ class BLOB_CHOICE: public ELIST_LINK
|
||||
UNICHAR_ID unichar_id_; // unichar id
|
||||
// Fonts and scores. Allowed to be empty.
|
||||
GenericVector<tesseract::ScoredFont> fonts_;
|
||||
inT16 fontinfo_id_; // char font information
|
||||
inT16 fontinfo_id2_; // 2nd choice font information
|
||||
int16_t fontinfo_id_; // char font information
|
||||
int16_t fontinfo_id2_; // 2nd choice font information
|
||||
// Rating is the classifier distance weighted by the length of the outline
|
||||
// in the blob. In terms of probability, classifier distance is -klog p such
|
||||
// that the resulting distance is in the range [0, 1] and then
|
||||
@ -216,8 +216,8 @@ class BLOB_CHOICE: public ELIST_LINK
|
||||
// Holds the position of this choice in the ratings matrix.
|
||||
// Used to location position in the matrix during path backtracking.
|
||||
MATRIX_COORD matrix_cell_;
|
||||
inT16 xgap_before_;
|
||||
inT16 xgap_after_;
|
||||
int16_t xgap_before_;
|
||||
int16_t xgap_after_;
|
||||
// X-height range (in image pixels) that this classification supports.
|
||||
float min_xheight_;
|
||||
float max_xheight_;
|
||||
@ -269,7 +269,7 @@ const char *ScriptPosToString(tesseract::ScriptPos script_pos);
|
||||
class WERD_CHOICE : public ELIST_LINK {
|
||||
public:
|
||||
static const float kBadRating;
|
||||
static const char *permuter_name(uinT8 permuter);
|
||||
static const char *permuter_name(uint8_t permuter);
|
||||
|
||||
WERD_CHOICE(const UNICHARSET *unicharset)
|
||||
: unicharset_(unicharset) { this->init(8); }
|
||||
@ -279,7 +279,7 @@ class WERD_CHOICE : public ELIST_LINK {
|
||||
const char *src_lengths,
|
||||
float src_rating,
|
||||
float src_certainty,
|
||||
uinT8 src_permuter,
|
||||
uint8_t src_permuter,
|
||||
const UNICHARSET &unicharset)
|
||||
: unicharset_(&unicharset) {
|
||||
this->init(src_string, src_lengths, src_rating,
|
||||
@ -339,7 +339,7 @@ class WERD_CHOICE : public ELIST_LINK {
|
||||
min_x_height_ = min_height;
|
||||
max_x_height_ = max_height;
|
||||
}
|
||||
inline uinT8 permuter() const {
|
||||
inline uint8_t permuter() const {
|
||||
return permuter_;
|
||||
}
|
||||
const char *permuter_name() const;
|
||||
@ -368,7 +368,7 @@ class WERD_CHOICE : public ELIST_LINK {
|
||||
inline void set_certainty(float new_val) {
|
||||
certainty_ = new_val;
|
||||
}
|
||||
inline void set_permuter(uinT8 perm) {
|
||||
inline void set_permuter(uint8_t perm) {
|
||||
permuter_ = perm;
|
||||
}
|
||||
// Note: this function should only be used if all the fields
|
||||
@ -433,7 +433,7 @@ class WERD_CHOICE : public ELIST_LINK {
|
||||
/// in src_string are assumed to all be of length 1.
|
||||
void init(const char *src_string, const char *src_lengths,
|
||||
float src_rating, float src_certainty,
|
||||
uinT8 src_permuter);
|
||||
uint8_t src_permuter);
|
||||
|
||||
/// Set the fields in this choice to be default (bad) values.
|
||||
inline void make_bad() {
|
||||
@ -619,7 +619,7 @@ class WERD_CHOICE : public ELIST_LINK {
|
||||
// xheight computed from the result, or 0 if inconsistent.
|
||||
float min_x_height_;
|
||||
float max_x_height_;
|
||||
uinT8 permuter_; // permuter code
|
||||
uint8_t permuter_; // permuter code
|
||||
|
||||
// Normally, the ratings_ matrix represents the recognition results in order
|
||||
// from left-to-right. However, some engines (say Cube) may return
|
||||
|
@ -62,7 +62,7 @@ TBOX::TBOX( // constructor
|
||||
**********************************************************************/
|
||||
|
||||
TBOX::TBOX( //constructor
|
||||
inT16 left, inT16 bottom, inT16 right, inT16 top)
|
||||
int16_t left, int16_t bottom, int16_t right, int16_t top)
|
||||
: bot_left(left, bottom), top_right(right, top) {
|
||||
}
|
||||
|
||||
@ -86,10 +86,10 @@ void TBOX::rotate_large(const FCOORD& vec) {
|
||||
|
||||
TBOX TBOX::intersection( //shared area box
|
||||
const TBOX &box) const {
|
||||
inT16 left;
|
||||
inT16 bottom;
|
||||
inT16 right;
|
||||
inT16 top;
|
||||
int16_t left;
|
||||
int16_t bottom;
|
||||
int16_t right;
|
||||
int16_t top;
|
||||
if (overlap (box)) {
|
||||
if (box.bot_left.x () > bot_left.x ())
|
||||
left = box.bot_left.x ();
|
||||
@ -112,10 +112,10 @@ TBOX TBOX::intersection( //shared area box
|
||||
top = top_right.y ();
|
||||
}
|
||||
else {
|
||||
left = MAX_INT16;
|
||||
bottom = MAX_INT16;
|
||||
top = -MAX_INT16;
|
||||
right = -MAX_INT16;
|
||||
left = INT16_MAX;
|
||||
bottom = INT16_MAX;
|
||||
top = -INT16_MAX;
|
||||
right = -INT16_MAX;
|
||||
}
|
||||
return TBOX (left, bottom, right, top);
|
||||
}
|
||||
@ -242,10 +242,10 @@ TBOX& operator&=(TBOX& op1, const TBOX& op2) {
|
||||
op1.top_right.set_y (op2.top_right.y ());
|
||||
}
|
||||
else {
|
||||
op1.bot_left.set_x (MAX_INT16);
|
||||
op1.bot_left.set_y (MAX_INT16);
|
||||
op1.top_right.set_x (-MAX_INT16);
|
||||
op1.top_right.set_y (-MAX_INT16);
|
||||
op1.bot_left.set_x (INT16_MAX);
|
||||
op1.bot_left.set_y (INT16_MAX);
|
||||
op1.top_right.set_x (-INT16_MAX);
|
||||
op1.top_right.set_y (-INT16_MAX);
|
||||
}
|
||||
return op1;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
class DLLSYM TBOX { // bounding box
|
||||
public:
|
||||
TBOX (): // empty constructor making a null box
|
||||
bot_left (MAX_INT16, MAX_INT16), top_right (-MAX_INT16, -MAX_INT16) {
|
||||
bot_left (INT16_MAX, INT16_MAX), top_right (-INT16_MAX, -INT16_MAX) {
|
||||
}
|
||||
|
||||
TBOX( // constructor
|
||||
@ -38,7 +38,7 @@ class DLLSYM TBOX { // bounding box
|
||||
const ICOORD pt2); // the other corner
|
||||
|
||||
TBOX( // constructor
|
||||
inT16 left, inT16 bottom, inT16 right, inT16 top);
|
||||
int16_t left, int16_t bottom, int16_t right, int16_t top);
|
||||
|
||||
TBOX( // box around FCOORD
|
||||
const FCOORD pt);
|
||||
@ -51,28 +51,28 @@ class DLLSYM TBOX { // bounding box
|
||||
return bot_left == other.bot_left && top_right == other.top_right;
|
||||
}
|
||||
|
||||
inT16 top() const { // coord of top
|
||||
int16_t top() const { // coord of top
|
||||
return top_right.y ();
|
||||
}
|
||||
void set_top(int y) {
|
||||
top_right.set_y(y);
|
||||
}
|
||||
|
||||
inT16 bottom() const { // coord of bottom
|
||||
int16_t bottom() const { // coord of bottom
|
||||
return bot_left.y ();
|
||||
}
|
||||
void set_bottom(int y) {
|
||||
bot_left.set_y(y);
|
||||
}
|
||||
|
||||
inT16 left() const { // coord of left
|
||||
int16_t left() const { // coord of left
|
||||
return bot_left.x ();
|
||||
}
|
||||
void set_left(int x) {
|
||||
bot_left.set_x(x);
|
||||
}
|
||||
|
||||
inT16 right() const { // coord of right
|
||||
int16_t right() const { // coord of right
|
||||
return top_right.x ();
|
||||
}
|
||||
void set_right(int x) {
|
||||
@ -101,21 +101,21 @@ class DLLSYM TBOX { // bounding box
|
||||
return top_right;
|
||||
}
|
||||
|
||||
inT16 height() const { // how high is it?
|
||||
int16_t height() const { // how high is it?
|
||||
if (!null_box ())
|
||||
return top_right.y () - bot_left.y ();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
inT16 width() const { // how high is it?
|
||||
int16_t width() const { // how high is it?
|
||||
if (!null_box ())
|
||||
return top_right.x () - bot_left.x ();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
inT32 area() const { // what is the area?
|
||||
int32_t area() const { // what is the area?
|
||||
if (!null_box ())
|
||||
return width () * height ();
|
||||
else
|
||||
@ -131,22 +131,22 @@ class DLLSYM TBOX { // bounding box
|
||||
}
|
||||
|
||||
void move_bottom_edge( // move one edge
|
||||
const inT16 y) { // by +/- y
|
||||
const int16_t y) { // by +/- y
|
||||
bot_left += ICOORD (0, y);
|
||||
}
|
||||
|
||||
void move_left_edge( // move one edge
|
||||
const inT16 x) { // by +/- x
|
||||
const int16_t x) { // by +/- x
|
||||
bot_left += ICOORD (x, 0);
|
||||
}
|
||||
|
||||
void move_right_edge( // move one edge
|
||||
const inT16 x) { // by +/- x
|
||||
const int16_t x) { // by +/- x
|
||||
top_right += ICOORD (x, 0);
|
||||
}
|
||||
|
||||
void move_top_edge( // move one edge
|
||||
const inT16 y) { // by +/- y
|
||||
const int16_t y) { // by +/- y
|
||||
top_right += ICOORD (0, y);
|
||||
}
|
||||
|
||||
@ -158,29 +158,29 @@ class DLLSYM TBOX { // bounding box
|
||||
|
||||
void move( // move box
|
||||
const FCOORD vec) { // by float vector
|
||||
bot_left.set_x ((inT16) floor (bot_left.x () + vec.x ()));
|
||||
bot_left.set_x ((int16_t) floor (bot_left.x () + vec.x ()));
|
||||
// round left
|
||||
bot_left.set_y ((inT16) floor (bot_left.y () + vec.y ()));
|
||||
bot_left.set_y ((int16_t) floor (bot_left.y () + vec.y ()));
|
||||
// round down
|
||||
top_right.set_x ((inT16) ceil (top_right.x () + vec.x ()));
|
||||
top_right.set_x ((int16_t) ceil (top_right.x () + vec.x ()));
|
||||
// round right
|
||||
top_right.set_y ((inT16) ceil (top_right.y () + vec.y ()));
|
||||
top_right.set_y ((int16_t) ceil (top_right.y () + vec.y ()));
|
||||
// round up
|
||||
}
|
||||
|
||||
void scale( // scale box
|
||||
const float f) { // by multiplier
|
||||
bot_left.set_x ((inT16) floor (bot_left.x () * f)); // round left
|
||||
bot_left.set_y ((inT16) floor (bot_left.y () * f)); // round down
|
||||
top_right.set_x ((inT16) ceil (top_right.x () * f)); // round right
|
||||
top_right.set_y ((inT16) ceil (top_right.y () * f)); // round up
|
||||
bot_left.set_x ((int16_t) floor (bot_left.x () * f)); // round left
|
||||
bot_left.set_y ((int16_t) floor (bot_left.y () * f)); // round down
|
||||
top_right.set_x ((int16_t) ceil (top_right.x () * f)); // round right
|
||||
top_right.set_y ((int16_t) ceil (top_right.y () * f)); // round up
|
||||
}
|
||||
void scale( // scale box
|
||||
const FCOORD vec) { // by float vector
|
||||
bot_left.set_x ((inT16) floor (bot_left.x () * vec.x ()));
|
||||
bot_left.set_y ((inT16) floor (bot_left.y () * vec.y ()));
|
||||
top_right.set_x ((inT16) ceil (top_right.x () * vec.x ()));
|
||||
top_right.set_y ((inT16) ceil (top_right.y () * vec.y ()));
|
||||
bot_left.set_x ((int16_t) floor (bot_left.x () * vec.x ()));
|
||||
bot_left.set_y ((int16_t) floor (bot_left.y () * vec.y ()));
|
||||
top_right.set_x ((int16_t) ceil (top_right.x () * vec.x ()));
|
||||
top_right.set_y ((int16_t) ceil (top_right.y () * vec.y ()));
|
||||
}
|
||||
|
||||
// rotate doesn't enlarge the box - it just rotates the bottom-left
|
||||
@ -310,8 +310,8 @@ class DLLSYM TBOX { // bounding box
|
||||
inline TBOX::TBOX( // constructor
|
||||
const FCOORD pt // floating centre
|
||||
) {
|
||||
bot_left = ICOORD ((inT16) floor (pt.x ()), (inT16) floor (pt.y ()));
|
||||
top_right = ICOORD ((inT16) ceil (pt.x ()), (inT16) ceil (pt.y ()));
|
||||
bot_left = ICOORD ((int16_t) floor (pt.x ()), (int16_t) floor (pt.y ()));
|
||||
top_right = ICOORD ((int16_t) ceil (pt.x ()), (int16_t) ceil (pt.y ()));
|
||||
}
|
||||
|
||||
|
||||
@ -400,7 +400,7 @@ inline bool TBOX::x_overlap(const TBOX &box) const {
|
||||
**********************************************************************/
|
||||
|
||||
inline bool TBOX::major_x_overlap(const TBOX &box) const {
|
||||
inT16 overlap = box.width();
|
||||
int16_t overlap = box.width();
|
||||
if (this->left() > box.left()) {
|
||||
overlap -= this->left() - box.left();
|
||||
}
|
||||
@ -427,7 +427,7 @@ inline bool TBOX::y_overlap(const TBOX &box) const {
|
||||
**********************************************************************/
|
||||
|
||||
inline bool TBOX::major_y_overlap(const TBOX &box) const {
|
||||
inT16 overlap = box.height();
|
||||
int16_t overlap = box.height();
|
||||
if (this->bottom() > box.bottom()) {
|
||||
overlap -= this->bottom() - box.bottom();
|
||||
}
|
||||
|
@ -272,15 +272,15 @@ REJMAP &REJMAP::operator=(const REJMAP &source) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void REJMAP::initialise(inT16 length) {
|
||||
void REJMAP::initialise(int16_t length) {
|
||||
ptr.reset(new REJ[length]);
|
||||
len = length;
|
||||
}
|
||||
|
||||
|
||||
inT16 REJMAP::accept_count() { //How many accepted?
|
||||
int16_t REJMAP::accept_count() { //How many accepted?
|
||||
int i;
|
||||
inT16 count = 0;
|
||||
int16_t count = 0;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (ptr[i].accepted ())
|
||||
@ -313,7 +313,7 @@ BOOL8 REJMAP::quality_recoverable_rejects() { //Any potential rejs?
|
||||
|
||||
|
||||
void REJMAP::remove_pos( //Cut out an element
|
||||
inT16 pos //element to remove
|
||||
int16_t pos //element to remove
|
||||
) {
|
||||
ASSERT_HOST (pos >= 0);
|
||||
ASSERT_HOST (pos < len);
|
||||
|
@ -204,7 +204,7 @@ class REJ
|
||||
class REJMAP
|
||||
{
|
||||
std::unique_ptr<REJ[]> ptr; // ptr to the chars
|
||||
inT16 len; // Number of chars
|
||||
int16_t len; //Number of chars
|
||||
|
||||
public:
|
||||
REJMAP() : len(0) {}
|
||||
@ -214,27 +214,27 @@ class REJMAP
|
||||
REJMAP &operator=(const REJMAP &source);
|
||||
|
||||
// Sets up the ptr array to length, whatever it was before.
|
||||
void initialise(inT16 length);
|
||||
void initialise(int16_t length);
|
||||
|
||||
REJ &operator[]( // access function
|
||||
inT16 index) const // map index
|
||||
REJ &operator[]( // access function
|
||||
int16_t index) const // map index
|
||||
{
|
||||
ASSERT_HOST(index < len);
|
||||
return ptr[index]; // no bounds checks
|
||||
}
|
||||
|
||||
inT32 length() const { //map length
|
||||
int32_t length() const { //map length
|
||||
return len;
|
||||
}
|
||||
|
||||
inT16 accept_count(); //How many accepted?
|
||||
int16_t accept_count(); //How many accepted?
|
||||
|
||||
inT16 reject_count() { //How many rejects?
|
||||
int16_t reject_count() { //How many rejects?
|
||||
return len - accept_count ();
|
||||
}
|
||||
|
||||
void remove_pos( //Cut out an element
|
||||
inT16 pos); //element to remove
|
||||
int16_t pos); //element to remove
|
||||
|
||||
void print(FILE *fp);
|
||||
|
||||
|
@ -186,8 +186,8 @@ class SEAM {
|
||||
// A range such that all splits in *this SEAM are contained within blobs in
|
||||
// the range [index - widthn_,index + widthp_] where index is the index of
|
||||
// this SEAM in the seams vector.
|
||||
inT8 widthp_;
|
||||
inT8 widthn_;
|
||||
int8_t widthp_;
|
||||
int8_t widthn_;
|
||||
// Number of splits_ that are used.
|
||||
uint8_t num_splits_;
|
||||
// Set of pairs of points that are the ends of each split in the SEAM.
|
||||
|
@ -37,14 +37,14 @@ using tesseract::KDPairInc;
|
||||
*
|
||||
* Construct a new stats element by allocating and zeroing the memory.
|
||||
**********************************************************************/
|
||||
STATS::STATS(inT32 min_bucket_value, inT32 max_bucket_value_plus_1) {
|
||||
STATS::STATS(int32_t min_bucket_value, int32_t max_bucket_value_plus_1) {
|
||||
if (max_bucket_value_plus_1 <= min_bucket_value) {
|
||||
min_bucket_value = 0;
|
||||
max_bucket_value_plus_1 = 1;
|
||||
}
|
||||
rangemin_ = min_bucket_value; // setup
|
||||
rangemax_ = max_bucket_value_plus_1;
|
||||
buckets_ = new inT32[rangemax_ - rangemin_];
|
||||
buckets_ = new int32_t[rangemax_ - rangemin_];
|
||||
clear();
|
||||
}
|
||||
|
||||
@ -59,13 +59,13 @@ STATS::STATS() {
|
||||
*
|
||||
* Alter the range on an existing stats element.
|
||||
**********************************************************************/
|
||||
bool STATS::set_range(inT32 min_bucket_value, inT32 max_bucket_value_plus_1) {
|
||||
bool STATS::set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1) {
|
||||
if (max_bucket_value_plus_1 <= min_bucket_value) {
|
||||
return false;
|
||||
}
|
||||
if (rangemax_ - rangemin_ != max_bucket_value_plus_1 - min_bucket_value) {
|
||||
delete [] buckets_;
|
||||
buckets_ = new inT32[max_bucket_value_plus_1 - min_bucket_value];
|
||||
buckets_ = new int32_t[max_bucket_value_plus_1 - min_bucket_value];
|
||||
}
|
||||
rangemin_ = min_bucket_value; // setup
|
||||
rangemax_ = max_bucket_value_plus_1;
|
||||
@ -96,7 +96,7 @@ STATS::~STATS() { delete[] buckets_; }
|
||||
*
|
||||
* Add a set of samples to (or delete from) a pile.
|
||||
**********************************************************************/
|
||||
void STATS::add(inT32 value, inT32 count) {
|
||||
void STATS::add(int32_t value, int32_t count) {
|
||||
if (buckets_ == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -110,12 +110,12 @@ void STATS::add(inT32 value, inT32 count) {
|
||||
*
|
||||
* Find the mode of a stats class.
|
||||
**********************************************************************/
|
||||
inT32 STATS::mode() const { // get mode of samples
|
||||
int32_t STATS::mode() const { // get mode of samples
|
||||
if (buckets_ == NULL) {
|
||||
return rangemin_;
|
||||
}
|
||||
inT32 max = buckets_[0]; // max cell count
|
||||
inT32 maxindex = 0; // index of max
|
||||
int32_t max = buckets_[0]; // max cell count
|
||||
int32_t maxindex = 0; // index of max
|
||||
for (int index = rangemax_ - rangemin_ - 1; index > 0; --index) {
|
||||
if (buckets_[index] > max) {
|
||||
max = buckets_[index]; // find biggest
|
||||
@ -134,9 +134,9 @@ double STATS::mean() const { //get mean of samples
|
||||
if (buckets_ == NULL || total_count_ <= 0) {
|
||||
return static_cast<double>(rangemin_);
|
||||
}
|
||||
inT64 sum = 0;
|
||||
int64_t sum = 0;
|
||||
for (int index = rangemax_ - rangemin_ - 1; index >= 0; --index) {
|
||||
sum += static_cast<inT64>(index) * buckets_[index];
|
||||
sum += static_cast<int64_t>(index) * buckets_[index];
|
||||
}
|
||||
return static_cast<double>(sum) / total_count_ + rangemin_;
|
||||
}
|
||||
@ -150,10 +150,10 @@ double STATS::sd() const { //standard deviation
|
||||
if (buckets_ == NULL || total_count_ <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
inT64 sum = 0;
|
||||
int64_t sum = 0;
|
||||
double sqsum = 0.0;
|
||||
for (int index = rangemax_ - rangemin_ - 1; index >= 0; --index) {
|
||||
sum += static_cast<inT64>(index) * buckets_[index];
|
||||
sum += static_cast<int64_t>(index) * buckets_[index];
|
||||
sqsum += static_cast<double>(index) * index * buckets_[index];
|
||||
}
|
||||
double variance = static_cast<double>(sum) / total_count_;
|
||||
@ -201,11 +201,11 @@ double STATS::ile(double frac) const {
|
||||
*
|
||||
* Find REAL minimum bucket - ile(0.0) isn't necessarily correct
|
||||
**********************************************************************/
|
||||
inT32 STATS::min_bucket() const { // Find min
|
||||
int32_t STATS::min_bucket() const { // Find min
|
||||
if (buckets_ == NULL || total_count_ == 0) {
|
||||
return rangemin_;
|
||||
}
|
||||
inT32 min = 0;
|
||||
int32_t min = 0;
|
||||
for (min = 0; (min < rangemax_ - rangemin_) && (buckets_[min] == 0); min++);
|
||||
return rangemin_ + min;
|
||||
}
|
||||
@ -216,11 +216,11 @@ inT32 STATS::min_bucket() const { // Find min
|
||||
* Find REAL maximum bucket - ile(1.0) isn't necessarily correct
|
||||
**********************************************************************/
|
||||
|
||||
inT32 STATS::max_bucket() const { // Find max
|
||||
int32_t STATS::max_bucket() const { // Find max
|
||||
if (buckets_ == NULL || total_count_ == 0) {
|
||||
return rangemin_;
|
||||
}
|
||||
inT32 max;
|
||||
int32_t max;
|
||||
for (max = rangemax_ - rangemin_ - 1; max > 0 && buckets_[max] == 0; max--);
|
||||
return rangemin_ + max;
|
||||
}
|
||||
@ -241,8 +241,8 @@ double STATS::median() const { //get median
|
||||
double median = ile(0.5);
|
||||
int median_pile = static_cast<int>(floor(median));
|
||||
if ((total_count_ > 1) && (pile_count(median_pile) == 0)) {
|
||||
inT32 min_pile;
|
||||
inT32 max_pile;
|
||||
int32_t min_pile;
|
||||
int32_t max_pile;
|
||||
/* Find preceding non zero pile */
|
||||
for (min_pile = median_pile; pile_count(min_pile) == 0; min_pile--);
|
||||
/* Find following non zero pile */
|
||||
@ -257,14 +257,14 @@ double STATS::median() const { //get median
|
||||
*
|
||||
* Return TRUE if this point is a local min.
|
||||
**********************************************************************/
|
||||
bool STATS::local_min(inT32 x) const {
|
||||
bool STATS::local_min(int32_t x) const {
|
||||
if (buckets_ == NULL) {
|
||||
return false;
|
||||
}
|
||||
x = ClipToRange(x, rangemin_, rangemax_ - 1) - rangemin_;
|
||||
if (buckets_[x] == 0)
|
||||
return true;
|
||||
inT32 index; // table index
|
||||
int32_t index; // table index
|
||||
for (index = x - 1; index >= 0 && buckets_[index] == buckets_[x]; --index);
|
||||
if (index >= 0 && buckets_[index] < buckets_[x])
|
||||
return false;
|
||||
@ -284,7 +284,7 @@ bool STATS::local_min(inT32 x) const {
|
||||
* The factor gives the height of the triangle, i.e. the weight of the
|
||||
* centre.
|
||||
**********************************************************************/
|
||||
void STATS::smooth(inT32 factor) {
|
||||
void STATS::smooth(int32_t factor) {
|
||||
if (buckets_ == NULL || factor < 2) {
|
||||
return;
|
||||
}
|
||||
@ -315,22 +315,22 @@ void STATS::smooth(inT32 factor) {
|
||||
* The return value is the current number of clusters.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 STATS::cluster(float lower, // thresholds
|
||||
int32_t STATS::cluster(float lower, // thresholds
|
||||
float upper,
|
||||
float multiple, // distance threshold
|
||||
inT32 max_clusters, // max no to make
|
||||
int32_t max_clusters, // max no to make
|
||||
STATS *clusters) { // array of clusters
|
||||
BOOL8 new_cluster; // added one
|
||||
float *centres; // cluster centres
|
||||
inT32 entry; // bucket index
|
||||
inT32 cluster; // cluster index
|
||||
inT32 best_cluster; // one to assign to
|
||||
inT32 new_centre = 0; // residual mode
|
||||
inT32 new_mode; // pile count of new_centre
|
||||
inT32 count; // pile to place
|
||||
int32_t entry; // bucket index
|
||||
int32_t cluster; // cluster index
|
||||
int32_t best_cluster; // one to assign to
|
||||
int32_t new_centre = 0; // residual mode
|
||||
int32_t new_mode; // pile count of new_centre
|
||||
int32_t count; // pile to place
|
||||
float dist; // from cluster
|
||||
float min_dist; // from best_cluster
|
||||
inT32 cluster_count; // no of clusters
|
||||
int32_t cluster_count; // no of clusters
|
||||
|
||||
if (buckets_ == NULL || max_clusters < 1)
|
||||
return 0;
|
||||
@ -375,7 +375,7 @@ inT32 STATS::cluster(float lower, // thresholds
|
||||
count = buckets_[entry] - clusters[0].buckets_[entry];
|
||||
//remaining pile
|
||||
if (count > 0) { //any to handle
|
||||
min_dist = static_cast<float>(MAX_INT32);
|
||||
min_dist = static_cast<float>(INT32_MAX);
|
||||
best_cluster = 0;
|
||||
for (cluster = 1; cluster <= cluster_count; cluster++) {
|
||||
dist = entry + rangemin_ - centres[cluster];
|
||||
@ -533,8 +533,8 @@ void STATS::print() const {
|
||||
if (buckets_ == NULL) {
|
||||
return;
|
||||
}
|
||||
inT32 min = min_bucket() - rangemin_;
|
||||
inT32 max = max_bucket() - rangemin_;
|
||||
int32_t min = min_bucket() - rangemin_;
|
||||
int32_t max = max_bucket() - rangemin_;
|
||||
|
||||
int num_printed = 0;
|
||||
for (int index = min; index <= max; index++) {
|
||||
@ -559,8 +559,8 @@ void STATS::print_summary() const {
|
||||
if (buckets_ == NULL) {
|
||||
return;
|
||||
}
|
||||
inT32 min = min_bucket();
|
||||
inT32 max = max_bucket();
|
||||
int32_t min = min_bucket();
|
||||
int32_t max = max_bucket();
|
||||
tprintf("Total count=%d\n", total_count_);
|
||||
tprintf("Min=%.2f Really=%d\n", ile(0.0), min);
|
||||
tprintf("Lower quartile=%.2f\n", ile(0.25));
|
||||
@ -633,11 +633,11 @@ void STATS::plotline(ScrollView* window, // to draw in
|
||||
* if the members were sorted, without actually sorting.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 choose_nth_item(inT32 index, float *array, inT32 count) {
|
||||
inT32 next_sample; // next one to do
|
||||
inT32 next_lesser; // space for new
|
||||
inT32 prev_greater; // last one saved
|
||||
inT32 equal_count; // no of equal ones
|
||||
int32_t choose_nth_item(int32_t index, float *array, int32_t count) {
|
||||
int32_t next_sample; // next one to do
|
||||
int32_t next_lesser; // space for new
|
||||
int32_t prev_greater; // last one saved
|
||||
int32_t equal_count; // no of equal ones
|
||||
float pivot; // proposed median
|
||||
float sample; // current sample
|
||||
|
||||
@ -656,7 +656,7 @@ inT32 choose_nth_item(inT32 index, float *array, inT32 count) {
|
||||
index = 0; // ensure legal
|
||||
else if (index >= count)
|
||||
index = count - 1;
|
||||
equal_count = (inT32) (rand() % count);
|
||||
equal_count = (int32_t) (rand() % count);
|
||||
pivot = array[equal_count];
|
||||
// fill gap
|
||||
array[equal_count] = array[0];
|
||||
@ -700,14 +700,14 @@ inT32 choose_nth_item(inT32 index, float *array, inT32 count) {
|
||||
* Returns the index of what would be the nth item in the array
|
||||
* if the members were sorted, without actually sorting.
|
||||
**********************************************************************/
|
||||
inT32 choose_nth_item(inT32 index, void *array, inT32 count, size_t size,
|
||||
int32_t choose_nth_item(int32_t index, void *array, int32_t count, size_t size,
|
||||
int (*compar)(const void*, const void*)) {
|
||||
int result; // of compar
|
||||
inT32 next_sample; // next one to do
|
||||
inT32 next_lesser; // space for new
|
||||
inT32 prev_greater; // last one saved
|
||||
inT32 equal_count; // no of equal ones
|
||||
inT32 pivot; // proposed median
|
||||
int32_t next_sample; // next one to do
|
||||
int32_t next_lesser; // space for new
|
||||
int32_t prev_greater; // last one saved
|
||||
int32_t equal_count; // no of equal ones
|
||||
int32_t pivot; // proposed median
|
||||
|
||||
if (count <= 1)
|
||||
return 0;
|
||||
@ -723,7 +723,7 @@ inT32 choose_nth_item(inT32 index, void *array, inT32 count, size_t size,
|
||||
index = 0; // ensure legal
|
||||
else if (index >= count)
|
||||
index = count - 1;
|
||||
pivot = (inT32) (rand () % count);
|
||||
pivot = (int32_t) (rand () % count);
|
||||
swap_entries (array, size, pivot, 0);
|
||||
next_lesser = 0;
|
||||
prev_greater = count;
|
||||
@ -763,8 +763,8 @@ inT32 choose_nth_item(inT32 index, void *array, inT32 count, size_t size,
|
||||
**********************************************************************/
|
||||
void swap_entries(void *array, // array of entries
|
||||
size_t size, // size of entry
|
||||
inT32 index1, // entries to swap
|
||||
inT32 index2) {
|
||||
int32_t index1, // entries to swap
|
||||
int32_t index2) {
|
||||
char tmp;
|
||||
char *ptr1; // to entries
|
||||
char *ptr2;
|
||||
|
@ -42,21 +42,21 @@ class STATS {
|
||||
// max_bucket_value_plus_1 - min_bucket_value to the array size.
|
||||
// TODO(rays) This is ugly. Convert the second argument to
|
||||
// max_bucket_value and all the code that uses it.
|
||||
STATS(inT32 min_bucket_value, inT32 max_bucket_value_plus_1);
|
||||
STATS(int32_t min_bucket_value, int32_t max_bucket_value_plus_1);
|
||||
STATS(); // empty for arrays
|
||||
|
||||
~STATS();
|
||||
|
||||
// (Re)Sets the range and clears the counts.
|
||||
// See the constructor for info on max and min values.
|
||||
bool set_range(inT32 min_bucket_value, inT32 max_bucket_value_plus_1);
|
||||
bool set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1);
|
||||
|
||||
void clear(); // empty buckets
|
||||
|
||||
void add(inT32 value, inT32 count);
|
||||
void add(int32_t value, int32_t count);
|
||||
|
||||
// "Accessors" return various statistics on the data.
|
||||
inT32 mode() const; // get mode of samples
|
||||
int32_t mode() const; // get mode of samples
|
||||
double mean() const; // get mean of samples
|
||||
double sd() const; // standard deviation
|
||||
// Returns the fractile value such that frac fraction (in [0,1]) of samples
|
||||
@ -65,17 +65,17 @@ class STATS {
|
||||
// Returns the minimum used entry in the histogram (ie the minimum of the
|
||||
// data, NOT the minimum of the supplied range, nor is it an index.)
|
||||
// Would normally be called min(), but that is a reserved word in VC++.
|
||||
inT32 min_bucket() const; // Find min
|
||||
int32_t min_bucket() const; // Find min
|
||||
// Returns the maximum used entry in the histogram (ie the maximum of the
|
||||
// data, NOT the maximum of the supplied range, nor is it an index.)
|
||||
inT32 max_bucket() const; // Find max
|
||||
int32_t max_bucket() const; // Find max
|
||||
// Finds a more useful estimate of median than ile(0.5).
|
||||
// Overcomes a problem with ile() - if the samples are, for example,
|
||||
// 6,6,13,14 ile(0.5) return 7.0 - when a more useful value would be midway
|
||||
// between 6 and 13 = 9.5
|
||||
double median() const; // get median of samples
|
||||
// Returns the count of the given value.
|
||||
inT32 pile_count(inT32 value ) const {
|
||||
int32_t pile_count(int32_t value ) const {
|
||||
if (value <= rangemin_)
|
||||
return buckets_[0];
|
||||
if (value >= rangemax_ - 1)
|
||||
@ -83,27 +83,27 @@ class STATS {
|
||||
return buckets_[value - rangemin_];
|
||||
}
|
||||
// Returns the total count of all buckets.
|
||||
inT32 get_total() const {
|
||||
int32_t get_total() const {
|
||||
return total_count_; // total of all piles
|
||||
}
|
||||
// Returns true if x is a local min.
|
||||
bool local_min(inT32 x) const;
|
||||
bool local_min(int32_t x) const;
|
||||
|
||||
// Apply a triangular smoothing filter to the stats.
|
||||
// This makes the modes a bit more useful.
|
||||
// The factor gives the height of the triangle, i.e. the weight of the
|
||||
// centre.
|
||||
void smooth(inT32 factor);
|
||||
void smooth(int32_t factor);
|
||||
|
||||
// Cluster the samples into max_cluster clusters.
|
||||
// Each call runs one iteration. The array of clusters must be
|
||||
// max_clusters+1 in size as cluster 0 is used to indicate which samples
|
||||
// have been used.
|
||||
// The return value is the current number of clusters.
|
||||
inT32 cluster(float lower, // thresholds
|
||||
int32_t cluster(float lower, // thresholds
|
||||
float upper,
|
||||
float multiple, // distance threshold
|
||||
inT32 max_clusters, // max no to make
|
||||
int32_t max_clusters, // max no to make
|
||||
STATS *clusters); // array of clusters
|
||||
|
||||
// Finds (at most) the top max_modes modes, well actually the whole peak around
|
||||
@ -141,29 +141,29 @@ class STATS {
|
||||
#endif // GRAPHICS_DISABLED
|
||||
|
||||
private:
|
||||
inT32 rangemin_; // min of range
|
||||
int32_t rangemin_; // min of range
|
||||
// rangemax_ is not well named as it is really one past the max.
|
||||
inT32 rangemax_; // max of range
|
||||
inT32 total_count_; // no of samples
|
||||
inT32* buckets_; // array of cells
|
||||
int32_t rangemax_; // max of range
|
||||
int32_t total_count_; // no of samples
|
||||
int32_t* buckets_; // array of cells
|
||||
};
|
||||
|
||||
// Returns the nth ordered item from the array, as if they were
|
||||
// ordered, but without ordering them, in linear time.
|
||||
// The array does get shuffled!
|
||||
inT32 choose_nth_item(inT32 index, // index to choose
|
||||
int32_t choose_nth_item(int32_t index, // index to choose
|
||||
float *array, // array of items
|
||||
inT32 count); // no of items
|
||||
int32_t count); // no of items
|
||||
// Generic version uses a defined comparator (with qsort semantics).
|
||||
inT32 choose_nth_item(inT32 index, // index to choose
|
||||
int32_t choose_nth_item(int32_t index, // index to choose
|
||||
void *array, // array of items
|
||||
inT32 count, // no of items
|
||||
int32_t count, // no of items
|
||||
size_t size, // element size
|
||||
int (*compar)(const void*, const void*)); // comparator
|
||||
// Swaps 2 entries in an array in-place.
|
||||
void swap_entries(void *array, // array of entries
|
||||
size_t size, // size of entry
|
||||
inT32 index1, // entries to swap
|
||||
inT32 index2);
|
||||
int32_t index1, // entries to swap
|
||||
int32_t index2);
|
||||
|
||||
#endif // TESSERACT_CCSTRUCT_STATISTC_H_
|
||||
|
@ -267,10 +267,10 @@ TBOX C_BLOB::bounding_box() const { // bounding box
|
||||
* Return the area of the blob.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 C_BLOB::area() { //area
|
||||
int32_t C_BLOB::area() { //area
|
||||
C_OUTLINE *outline; //current outline
|
||||
C_OUTLINE_IT it = &outlines; //outlines of blob
|
||||
inT32 total; //total area
|
||||
int32_t total; //total area
|
||||
|
||||
total = 0;
|
||||
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
|
||||
@ -286,10 +286,10 @@ inT32 C_BLOB::area() { //area
|
||||
* Return the perimeter of the top and 2nd level outlines.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 C_BLOB::perimeter() {
|
||||
int32_t C_BLOB::perimeter() {
|
||||
C_OUTLINE *outline; // current outline
|
||||
C_OUTLINE_IT it = &outlines; // outlines of blob
|
||||
inT32 total; // total perimeter
|
||||
int32_t total; // total perimeter
|
||||
|
||||
total = 0;
|
||||
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
|
||||
@ -306,10 +306,10 @@ inT32 C_BLOB::perimeter() {
|
||||
* Return the area of the blob.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 C_BLOB::outer_area() { //area
|
||||
int32_t C_BLOB::outer_area() { //area
|
||||
C_OUTLINE *outline; //current outline
|
||||
C_OUTLINE_IT it = &outlines; //outlines of blob
|
||||
inT32 total; //total area
|
||||
int32_t total; //total area
|
||||
|
||||
total = 0;
|
||||
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
|
||||
@ -327,12 +327,12 @@ inT32 C_BLOB::outer_area() { //area
|
||||
* Chlid outlines are not counted.
|
||||
**********************************************************************/
|
||||
|
||||
inT32 C_BLOB::count_transitions( //area
|
||||
inT32 threshold //on size
|
||||
int32_t C_BLOB::count_transitions( //area
|
||||
int32_t threshold //on size
|
||||
) {
|
||||
C_OUTLINE *outline; //current outline
|
||||
C_OUTLINE_IT it = &outlines; //outlines of blob
|
||||
inT32 total; //total area
|
||||
int32_t total; //total area
|
||||
|
||||
total = 0;
|
||||
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
|
||||
@ -424,7 +424,7 @@ void C_BLOB::ComputeEdgeOffsets(int threshold, Pix* pix) {
|
||||
// |- -|
|
||||
// | -|
|
||||
// |---| <= Bottom of blob
|
||||
inT16 C_BLOB::EstimateBaselinePosition() {
|
||||
int16_t C_BLOB::EstimateBaselinePosition() {
|
||||
TBOX box = bounding_box();
|
||||
int left = box.left();
|
||||
int width = box.width();
|
||||
|
@ -66,11 +66,11 @@ class C_BLOB:public ELIST_LINK
|
||||
}
|
||||
|
||||
TBOX bounding_box() const; // compute bounding box
|
||||
inT32 area(); //compute area
|
||||
inT32 perimeter(); // Total perimeter of outlines and 1st level children.
|
||||
inT32 outer_area(); //compute area
|
||||
inT32 count_transitions( //count maxima
|
||||
inT32 threshold); //size threshold
|
||||
int32_t area(); //compute area
|
||||
int32_t perimeter(); // Total perimeter of outlines and 1st level children.
|
||||
int32_t outer_area(); //compute area
|
||||
int32_t count_transitions( //count maxima
|
||||
int32_t threshold); //size threshold
|
||||
|
||||
void move(const ICOORD vec); // repostion blob by vector
|
||||
void rotate(const FCOORD& rotation); // Rotate by given vector.
|
||||
@ -81,7 +81,7 @@ class C_BLOB:public ELIST_LINK
|
||||
|
||||
// Estimates and returns the baseline position based on the shape of the
|
||||
// outlines.
|
||||
inT16 EstimateBaselinePosition();
|
||||
int16_t EstimateBaselinePosition();
|
||||
|
||||
// Returns a Pix rendering of the blob. pixDestroy after use.
|
||||
Pix* render();
|
||||
|
@ -45,7 +45,7 @@ ELIST2IZE(WERD)
|
||||
* blank_count blanks in front of the word
|
||||
* text correct text, outlives this WERD
|
||||
*/
|
||||
WERD::WERD(C_BLOB_LIST *blob_list, uinT8 blank_count, const char *text)
|
||||
WERD::WERD(C_BLOB_LIST *blob_list, uint8_t blank_count, const char *text)
|
||||
: blanks(blank_count),
|
||||
flags(0),
|
||||
script_id_(0),
|
||||
@ -53,8 +53,8 @@ WERD::WERD(C_BLOB_LIST *blob_list, uinT8 blank_count, const char *text)
|
||||
C_BLOB_IT start_it = &cblobs;
|
||||
C_BLOB_IT rej_cblob_it = &rej_cblobs;
|
||||
C_OUTLINE_IT c_outline_it;
|
||||
inT16 inverted_vote = 0;
|
||||
inT16 non_inverted_vote = 0;
|
||||
int16_t inverted_vote = 0;
|
||||
int16_t non_inverted_vote = 0;
|
||||
|
||||
// Move blob_list's elements into cblobs.
|
||||
start_it.add_list_after(blob_list);
|
||||
|
@ -64,7 +64,7 @@ class WERD : public ELIST2_LINK {
|
||||
// blob_list - blobs of the word (we take this list's contents)
|
||||
// blanks - number of blanks before the word
|
||||
// text - correct text (outlives WERD)
|
||||
WERD(C_BLOB_LIST *blob_list, uinT8 blanks, const char *text);
|
||||
WERD(C_BLOB_LIST *blob_list, uint8_t blanks, const char *text);
|
||||
|
||||
// WERD constructed from:
|
||||
// blob_list - blobs in the word
|
||||
@ -101,10 +101,10 @@ class WERD : public ELIST2_LINK {
|
||||
return &cblobs;
|
||||
}
|
||||
|
||||
uinT8 space() { // access function
|
||||
uint8_t space() { // access function
|
||||
return blanks;
|
||||
}
|
||||
void set_blanks(uinT8 new_blanks) {
|
||||
void set_blanks(uint8_t new_blanks) {
|
||||
blanks = new_blanks;
|
||||
}
|
||||
int script_id() const {
|
||||
@ -128,8 +128,8 @@ class WERD : public ELIST2_LINK {
|
||||
BOOL8 flag(WERD_FLAGS mask) const { return flags.bit(mask); }
|
||||
void set_flag(WERD_FLAGS mask, BOOL8 value) { flags.set_bit(mask, value); }
|
||||
|
||||
BOOL8 display_flag(uinT8 flag) const { return disp_flags.bit(flag); }
|
||||
void set_display_flag(uinT8 flag, BOOL8 value) {
|
||||
BOOL8 display_flag(uint8_t flag) const { return disp_flags.bit(flag); }
|
||||
void set_display_flag(uint8_t flag, BOOL8 value) {
|
||||
disp_flags.set_bit(flag, value);
|
||||
}
|
||||
|
||||
@ -182,11 +182,11 @@ class WERD : public ELIST2_LINK {
|
||||
bool *make_next_word_fuzzy);
|
||||
|
||||
private:
|
||||
uinT8 blanks; // no of blanks
|
||||
uinT8 dummy; // padding
|
||||
uint8_t blanks; // no of blanks
|
||||
uint8_t dummy; // padding
|
||||
BITS16 flags; // flags about word
|
||||
BITS16 disp_flags; // display flags
|
||||
inT16 script_id_; // From unicharset.
|
||||
int16_t script_id_; // From unicharset.
|
||||
STRING correct; // correct text
|
||||
C_BLOB_LIST cblobs; // compacted blobs
|
||||
C_BLOB_LIST rej_cblobs; // DUFF blobs
|
||||
|
@ -24,6 +24,6 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
BITS16::BITS16( // constructor
|
||||
uinT16 init) { // initial val
|
||||
uint16_t init) { // initial val
|
||||
val = init;
|
||||
}
|
||||
|
@ -25,27 +25,27 @@
|
||||
class DLLSYM BITS16
|
||||
{
|
||||
public:
|
||||
uinT16 val;
|
||||
uint16_t val;
|
||||
|
||||
BITS16() {
|
||||
val = 0;
|
||||
} // constructor
|
||||
|
||||
BITS16( // constructor
|
||||
uinT16 init); // initial val
|
||||
uint16_t init); // initial val
|
||||
|
||||
void turn_on_bit( // flip specified bit
|
||||
uinT8 bit_num) { // bit to flip 0..7
|
||||
uint8_t bit_num) { // bit to flip 0..7
|
||||
val = val | 01 << bit_num;
|
||||
}
|
||||
|
||||
void turn_off_bit( // flip specified bit
|
||||
uinT8 bit_num) { // bit to flip 0..7
|
||||
uint8_t bit_num) { // bit to flip 0..7
|
||||
val = val & ~(01 << bit_num);
|
||||
}
|
||||
|
||||
void set_bit( // flip specified bit
|
||||
uinT8 bit_num, // bit to flip 0..7
|
||||
uint8_t bit_num, // bit to flip 0..7
|
||||
BOOL8 value) { // value to flip to
|
||||
if (value)
|
||||
val = val | 01 << bit_num;
|
||||
@ -54,7 +54,7 @@ class DLLSYM BITS16
|
||||
}
|
||||
|
||||
BOOL8 bit( // access bit
|
||||
uinT8 bit_num) const { // bit to access
|
||||
uint8_t bit_num) const { // bit to access
|
||||
return (val >> bit_num) & 01;
|
||||
}
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ namespace tesseract {
|
||||
// Fast lookup table to get the first least significant set bit in a byte.
|
||||
// For zero, the table has 255, but since it is a special case, most code
|
||||
// that uses this table will check for zero before looking up lsb_index_.
|
||||
const uinT8 BitVector::lsb_index_[256] = {
|
||||
const uint8_t BitVector::lsb_index_[256] = {
|
||||
255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
||||
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
||||
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
||||
@ -50,7 +50,7 @@ const uinT8 BitVector::lsb_index_[256] = {
|
||||
|
||||
// Fast lookup table to get the residual bits after zeroing the first (lowest)
|
||||
// set bit in a byte.
|
||||
const uinT8 BitVector::lsb_eroded_[256] = {
|
||||
const uint8_t BitVector::lsb_eroded_[256] = {
|
||||
0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6,
|
||||
0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e,
|
||||
0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16,
|
||||
@ -109,12 +109,12 @@ const int BitVector::hamming_table_[256] = {
|
||||
BitVector::BitVector() : bit_size_(0), array_(NULL) {}
|
||||
|
||||
BitVector::BitVector(int length) : bit_size_(length) {
|
||||
array_ = new uinT32[WordLength()];
|
||||
array_ = new uint32_t[WordLength()];
|
||||
SetAllFalse();
|
||||
}
|
||||
|
||||
BitVector::BitVector(const BitVector& src) : bit_size_(src.bit_size_) {
|
||||
array_ = new uinT32[WordLength()];
|
||||
array_ = new uint32_t[WordLength()];
|
||||
memcpy(array_, src.array_, ByteLength());
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ bool BitVector::Serialize(FILE* fp) const {
|
||||
// Reads from the given file. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool BitVector::DeSerialize(bool swap, FILE* fp) {
|
||||
uinT32 new_bit_size;
|
||||
uint32_t new_bit_size;
|
||||
if (fread(&new_bit_size, sizeof(new_bit_size), 1, fp) != 1) return false;
|
||||
if (swap) {
|
||||
ReverseN(&new_bit_size, sizeof(new_bit_size));
|
||||
@ -179,8 +179,8 @@ int BitVector::NextSetBit(int prev_bit) const {
|
||||
int next_word = WordIndex(next_bit);
|
||||
int bit_index = next_word * kBitFactor;
|
||||
int word_end = bit_index + kBitFactor;
|
||||
uinT32 word = array_[next_word];
|
||||
uinT8 byte = word & 0xff;
|
||||
uint32_t word = array_[next_word];
|
||||
uint8_t byte = word & 0xff;
|
||||
while (bit_index < word_end) {
|
||||
if (bit_index + 8 > next_bit && byte != 0) {
|
||||
while (bit_index + lsb_index_[byte] < next_bit && byte != 0)
|
||||
@ -213,7 +213,7 @@ int BitVector::NumSetBits() const {
|
||||
int wordlen = WordLength();
|
||||
int total_bits = 0;
|
||||
for (int w = 0; w < wordlen; ++w) {
|
||||
uinT32 word = array_[w];
|
||||
uint32_t word = array_[w];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
total_bits += hamming_table_[word & 0xff];
|
||||
word >>= 8;
|
||||
@ -259,7 +259,7 @@ void BitVector::Alloc(int length) {
|
||||
int new_wordlength = WordLength();
|
||||
if (new_wordlength != initial_wordlength) {
|
||||
delete [] array_;
|
||||
array_ = new uinT32[new_wordlength];
|
||||
array_ = new uint32_t[new_wordlength];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,10 @@ class BitVector {
|
||||
// Fast lookup table to get the first least significant set bit in a byte.
|
||||
// For zero, the table has 255, but since it is a special case, most code
|
||||
// that uses this table will check for zero before looking up lsb_index_.
|
||||
static const uinT8 lsb_index_[256];
|
||||
static const uint8_t lsb_index_[256];
|
||||
// Fast lookup table to get the residual bits after zeroing the least
|
||||
// significant set bit in a byte.
|
||||
static const uinT8 lsb_eroded_[256];
|
||||
static const uint8_t lsb_eroded_[256];
|
||||
// Fast lookup table to give the number of set bits in a byte.
|
||||
static const int hamming_table_[256];
|
||||
|
||||
@ -114,7 +114,7 @@ class BitVector {
|
||||
return index / kBitFactor;
|
||||
}
|
||||
// Returns a mask to select the appropriate bit for the given index.
|
||||
uinT32 BitMask(int index) const {
|
||||
uint32_t BitMask(int index) const {
|
||||
return 1 << (index & (kBitFactor - 1));
|
||||
}
|
||||
// Returns the number of array elements needed to represent the current
|
||||
@ -128,13 +128,13 @@ class BitVector {
|
||||
}
|
||||
|
||||
// Number of bits in this BitVector.
|
||||
inT32 bit_size_;
|
||||
int32_t bit_size_;
|
||||
// Array of words used to pack the bits.
|
||||
// Bits are stored little-endian by uinT32 word, ie by word first and then
|
||||
// Bits are stored little-endian by uint32_t word, ie by word first and then
|
||||
// starting with the least significant bit in each word.
|
||||
uinT32* array_;
|
||||
uint32_t* array_;
|
||||
// Number of bits in an array_ element.
|
||||
static const int kBitFactor = sizeof(uinT32) * 8;
|
||||
static const int kBitFactor = sizeof(uint32_t) * 8;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
@ -112,9 +112,9 @@ void CLIST::assign_to_sublist( //to this list
|
||||
* Return count of elements on list
|
||||
**********************************************************************/
|
||||
|
||||
inT32 CLIST::length() const { //count elements
|
||||
int32_t CLIST::length() const { //count elements
|
||||
CLIST_ITERATOR it(const_cast<CLIST*>(this));
|
||||
inT32 count = 0;
|
||||
int32_t count = 0;
|
||||
|
||||
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward())
|
||||
count++;
|
||||
@ -132,10 +132,10 @@ CLIST::sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
const void *, const void *)) {
|
||||
CLIST_ITERATOR it(this);
|
||||
inT32 count;
|
||||
int32_t count;
|
||||
void **base; //ptr array to sort
|
||||
void **current;
|
||||
inT32 i;
|
||||
int32_t i;
|
||||
|
||||
/* Allocate an array of pointers, one per list element */
|
||||
count = length ();
|
||||
@ -283,7 +283,7 @@ void *CLIST_ITERATOR::forward() {
|
||||
**********************************************************************/
|
||||
|
||||
void *CLIST_ITERATOR::data_relative( //get data + or - ...
|
||||
inT8 offset) { //offset from current
|
||||
int8_t offset) { //offset from current
|
||||
CLIST_LINK *ptr;
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -109,7 +109,7 @@ class DLLSYM CLIST
|
||||
CLIST_ITERATOR *start_it, //from list start
|
||||
CLIST_ITERATOR *end_it); //from list end
|
||||
|
||||
inT32 length() const; //# elements in list
|
||||
int32_t length() const; //# elements in list
|
||||
|
||||
void sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
@ -202,7 +202,7 @@ class DLLSYM CLIST_ITERATOR
|
||||
}
|
||||
|
||||
void *data_relative( //get data + or - ...
|
||||
inT8 offset); //offset from current
|
||||
int8_t offset); //offset from current
|
||||
|
||||
void *forward(); //move to next element
|
||||
|
||||
@ -238,7 +238,7 @@ class DLLSYM CLIST_ITERATOR
|
||||
void exchange( //positions of 2 links
|
||||
CLIST_ITERATOR *other_it); //other iterator
|
||||
|
||||
inT32 length(); //# elements in list
|
||||
int32_t length(); //# elements in list
|
||||
|
||||
void sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
@ -705,7 +705,7 @@ inline BOOL8 CLIST_ITERATOR::cycled_list() {
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
inline inT32 CLIST_ITERATOR::length() {
|
||||
inline int32_t CLIST_ITERATOR::length() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
NO_LIST.error ("CLIST_ITERATOR::length", ABORT, NULL);
|
||||
@ -881,7 +881,7 @@ CLISTIZEH_C.
|
||||
\
|
||||
CLASSNAME *data() { return (CLASSNAME *)CLIST_ITERATOR::data(); } \
|
||||
\
|
||||
CLASSNAME *data_relative(inT8 offset) { \
|
||||
CLASSNAME *data_relative(int8_t offset) { \
|
||||
return (CLASSNAME *)CLIST_ITERATOR::data_relative(offset); \
|
||||
} \
|
||||
\
|
||||
|
@ -87,9 +87,9 @@ void ELIST::assign_to_sublist( //to this list
|
||||
* Return count of elements on list
|
||||
**********************************************************************/
|
||||
|
||||
inT32 ELIST::length() const { // count elements
|
||||
int32_t ELIST::length() const { // count elements
|
||||
ELIST_ITERATOR it(const_cast<ELIST*>(this));
|
||||
inT32 count = 0;
|
||||
int32_t count = 0;
|
||||
|
||||
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
|
||||
count++;
|
||||
@ -109,10 +109,10 @@ ELIST::sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
const void *, const void *)) {
|
||||
ELIST_ITERATOR it(this);
|
||||
inT32 count;
|
||||
int32_t count;
|
||||
ELIST_LINK **base; //ptr array to sort
|
||||
ELIST_LINK **current;
|
||||
inT32 i;
|
||||
int32_t i;
|
||||
|
||||
/* Allocate an array of pointers, one per list element */
|
||||
count = length ();
|
||||
@ -231,7 +231,7 @@ ELIST_LINK *ELIST_ITERATOR::forward() {
|
||||
**********************************************************************/
|
||||
|
||||
ELIST_LINK *ELIST_ITERATOR::data_relative( //get data + or - ...
|
||||
inT8 offset) { //offset from current
|
||||
int8_t offset) { //offset from current
|
||||
ELIST_LINK *ptr;
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -150,7 +150,7 @@ class DLLSYM ELIST
|
||||
ELIST_ITERATOR *start_it, //from list start
|
||||
ELIST_ITERATOR *end_it); //from list end
|
||||
|
||||
inT32 length() const; // # elements in list
|
||||
int32_t length() const; // # elements in list
|
||||
|
||||
void sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
@ -243,7 +243,7 @@ class DLLSYM ELIST_ITERATOR
|
||||
}
|
||||
|
||||
ELIST_LINK *data_relative( //get data + or - ...
|
||||
inT8 offset); //offset from current
|
||||
int8_t offset); //offset from current
|
||||
|
||||
ELIST_LINK *forward(); //move to next element
|
||||
|
||||
@ -279,7 +279,7 @@ class DLLSYM ELIST_ITERATOR
|
||||
void exchange( //positions of 2 links
|
||||
ELIST_ITERATOR *other_it); //other iterator
|
||||
|
||||
inT32 length(); //# elements in list
|
||||
int32_t length(); //# elements in list
|
||||
|
||||
void sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
@ -746,7 +746,7 @@ inline bool ELIST_ITERATOR::cycled_list() {
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
inline inT32 ELIST_ITERATOR::length() {
|
||||
inline int32_t ELIST_ITERATOR::length() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
NO_LIST.error ("ELIST_ITERATOR::length", ABORT, NULL);
|
||||
@ -924,7 +924,7 @@ class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR { \
|
||||
return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data()); \
|
||||
} \
|
||||
\
|
||||
CLASSNAME* data_relative(inT8 offset) { \
|
||||
CLASSNAME* data_relative(int8_t offset) { \
|
||||
return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data_relative(offset));\
|
||||
} \
|
||||
\
|
||||
|
@ -88,9 +88,9 @@ void ELIST2::assign_to_sublist( //to this list
|
||||
* Return count of elements on list
|
||||
**********************************************************************/
|
||||
|
||||
inT32 ELIST2::length() const { // count elements
|
||||
int32_t ELIST2::length() const { // count elements
|
||||
ELIST2_ITERATOR it(const_cast<ELIST2*>(this));
|
||||
inT32 count = 0;
|
||||
int32_t count = 0;
|
||||
|
||||
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
|
||||
count++;
|
||||
@ -110,10 +110,10 @@ ELIST2::sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
const void *, const void *)) {
|
||||
ELIST2_ITERATOR it(this);
|
||||
inT32 count;
|
||||
int32_t count;
|
||||
ELIST2_LINK **base; //ptr array to sort
|
||||
ELIST2_LINK **current;
|
||||
inT32 i;
|
||||
int32_t i;
|
||||
|
||||
/* Allocate an array of pointers, one per list element */
|
||||
count = length ();
|
||||
@ -268,7 +268,7 @@ ELIST2_LINK *ELIST2_ITERATOR::backward() {
|
||||
**********************************************************************/
|
||||
|
||||
ELIST2_LINK *ELIST2_ITERATOR::data_relative( //get data + or - ..
|
||||
inT8 offset) { //offset from current
|
||||
int8_t offset) { //offset from current
|
||||
ELIST2_LINK *ptr;
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -125,7 +125,7 @@ class DLLSYM ELIST2
|
||||
ELIST2_ITERATOR *start_it, //from list start
|
||||
ELIST2_ITERATOR *end_it); //from list end
|
||||
|
||||
inT32 length() const; // # elements in list
|
||||
int32_t length() const; // # elements in list
|
||||
|
||||
void sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
@ -208,7 +208,7 @@ class DLLSYM ELIST2_ITERATOR
|
||||
}
|
||||
|
||||
ELIST2_LINK *data_relative( //get data + or - ...
|
||||
inT8 offset); //offset from current
|
||||
int8_t offset); //offset from current
|
||||
|
||||
ELIST2_LINK *forward(); //move to next element
|
||||
|
||||
@ -247,7 +247,7 @@ class DLLSYM ELIST2_ITERATOR
|
||||
void exchange( //positions of 2 links
|
||||
ELIST2_ITERATOR *other_it); //other iterator
|
||||
|
||||
inT32 length(); //# elements in list
|
||||
int32_t length(); //# elements in list
|
||||
|
||||
void sort ( //sort elements
|
||||
int comparator ( //comparison routine
|
||||
@ -749,7 +749,7 @@ inline BOOL8 ELIST2_ITERATOR::cycled_list() {
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
inline inT32 ELIST2_ITERATOR::length() {
|
||||
inline int32_t ELIST2_ITERATOR::length() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
NO_LIST.error ("ELIST2_ITERATOR::length", ABORT, NULL);
|
||||
@ -928,7 +928,7 @@ ELIST2IZEH_C.
|
||||
\
|
||||
CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \
|
||||
\
|
||||
CLASSNAME *data_relative(inT8 offset) { \
|
||||
CLASSNAME *data_relative(int8_t offset) { \
|
||||
return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \
|
||||
} \
|
||||
\
|
||||
|
@ -51,18 +51,18 @@ class TRand {
|
||||
set_seed(static_cast<uint64_t>(hasher(str)));
|
||||
}
|
||||
|
||||
// Returns an integer in the range 0 to MAX_INT32.
|
||||
// Returns an integer in the range 0 to INT32_MAX.
|
||||
int32_t IntRand() {
|
||||
Iterate();
|
||||
return seed_ >> 33;
|
||||
}
|
||||
// Returns a floating point value in the range [-range, range].
|
||||
double SignedRand(double range) {
|
||||
return range * 2.0 * IntRand() / MAX_INT32 - range;
|
||||
return range * 2.0 * IntRand() / INT32_MAX - range;
|
||||
}
|
||||
// Returns a floating point value in the range [0, range].
|
||||
double UnsignedRand(double range) {
|
||||
return range * IntRand() / MAX_INT32;
|
||||
return range * IntRand() / INT32_MAX;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -31,14 +31,6 @@
|
||||
#include <cstdint> // int32_t, ...
|
||||
|
||||
// definitions of portable data types (numbers and characters)
|
||||
typedef int8_t inT8;
|
||||
typedef uint8_t uinT8;
|
||||
typedef int16_t inT16;
|
||||
typedef uint16_t uinT16;
|
||||
typedef int32_t inT32;
|
||||
typedef uint32_t uinT32;
|
||||
typedef int64_t inT64;
|
||||
typedef uint64_t uinT64;
|
||||
typedef float FLOAT32;
|
||||
typedef double FLOAT64;
|
||||
typedef unsigned char BOOL8;
|
||||
@ -57,20 +49,8 @@ typedef unsigned char BOOL8;
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#define MAX_INT8 0x7f
|
||||
#define MAX_INT16 0x7fff
|
||||
#define MAX_INT32 0x7fffffff
|
||||
#define MAX_UINT8 0xff
|
||||
#define MAX_UINT16 0xffff
|
||||
#define MAX_UINT32 0xffffffff
|
||||
#define MAX_FLOAT32 std::numeric_limits<float>::max()
|
||||
|
||||
#define MIN_INT8 static_cast<int8_t>(0x80)
|
||||
#define MIN_INT16 static_cast<int16_t>(0x8000)
|
||||
#define MIN_INT32 static_cast<int32_t>(0x80000000)
|
||||
#define MIN_UINT8 0x00
|
||||
#define MIN_UINT16 0x0000
|
||||
#define MIN_UINT32 0x00000000
|
||||
// Minimum positive value ie 1e-37ish.
|
||||
#define MIN_FLOAT32 std::numeric_limits<float>::min()
|
||||
|
||||
|
@ -41,7 +41,7 @@ void IndexMap::CopyFrom(const IndexMapBiDi& src) {
|
||||
|
||||
// Writes to the given file. Returns false in case of error.
|
||||
bool IndexMap::Serialize(FILE* fp) const {
|
||||
inT32 sparse_size = sparse_size_;
|
||||
int32_t sparse_size = sparse_size_;
|
||||
if (fwrite(&sparse_size, sizeof(sparse_size), 1, fp) != 1) return false;
|
||||
if (!compact_map_.Serialize(fp)) return false;
|
||||
return true;
|
||||
@ -50,7 +50,7 @@ bool IndexMap::Serialize(FILE* fp) const {
|
||||
// Reads from the given file. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool IndexMap::DeSerialize(bool swap, FILE* fp) {
|
||||
inT32 sparse_size;
|
||||
int32_t sparse_size;
|
||||
if (fread(&sparse_size, sizeof(sparse_size), 1, fp) != 1) return false;
|
||||
if (swap)
|
||||
ReverseN(&sparse_size, sizeof(sparse_size));
|
||||
@ -169,7 +169,7 @@ void IndexMapBiDi::CompleteMerges() {
|
||||
}
|
||||
// Compact the compact_map, leaving tmp_compact_map saying where each
|
||||
// index went to in the compacted map.
|
||||
GenericVector<inT32> tmp_compact_map;
|
||||
GenericVector<int32_t> tmp_compact_map;
|
||||
tmp_compact_map.init_to_size(compact_size, -1);
|
||||
compact_size = 0;
|
||||
for (int i = 0; i < compact_map_.size(); ++i) {
|
||||
@ -193,7 +193,7 @@ bool IndexMapBiDi::Serialize(FILE* fp) const {
|
||||
// Make a vector containing the rest of the map. If the map is many-to-one
|
||||
// then each additional sparse entry needs to be stored.
|
||||
// Normally we store only the compact map to save space.
|
||||
GenericVector<inT32> remaining_pairs;
|
||||
GenericVector<int32_t> remaining_pairs;
|
||||
for (int i = 0; i < sparse_map_.size(); ++i) {
|
||||
if (sparse_map_[i] >= 0 && compact_map_[sparse_map_[i]] != i) {
|
||||
remaining_pairs.push_back(i);
|
||||
@ -208,7 +208,7 @@ bool IndexMapBiDi::Serialize(FILE* fp) const {
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool IndexMapBiDi::DeSerialize(bool swap, FILE* fp) {
|
||||
if (!IndexMap::DeSerialize(swap, fp)) return false;
|
||||
GenericVector<inT32> remaining_pairs;
|
||||
GenericVector<int32_t> remaining_pairs;
|
||||
if (!remaining_pairs.DeSerialize(swap, fp)) return false;
|
||||
sparse_map_.init_to_size(sparse_size_, -1);
|
||||
for (int i = 0; i < compact_map_.size(); ++i) {
|
||||
|
@ -77,7 +77,7 @@ class IndexMap {
|
||||
int sparse_size_;
|
||||
// The compact space covers integers in the range [0, compact_map_.size()-1].
|
||||
// Each element contains the corresponding sparse index.
|
||||
GenericVector<inT32> compact_map_;
|
||||
GenericVector<int32_t> compact_map_;
|
||||
};
|
||||
|
||||
// Bidirectional many-to-one mapping between a sparse and a compact discrete
|
||||
@ -172,7 +172,7 @@ class IndexMapBiDi : public IndexMap {
|
||||
}
|
||||
|
||||
// Direct look-up of the compact index for each element in sparse space.
|
||||
GenericVector<inT32> sparse_map_;
|
||||
GenericVector<int32_t> sparse_map_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
@ -42,15 +42,15 @@ REALLY_DECLARE_MAIN(ARGC,ARGV)
|
||||
* whitespace spaced string being an arg.\
|
||||
**********************************************************************/\
|
||||
\
|
||||
inT32 parse_args( /*refine arg list*/\
|
||||
inT32 argc, /*no of input args*/\
|
||||
int32_t parse_args( /*refine arg list*/\
|
||||
int32_t argc, /*no of input args*/\
|
||||
char *argv[], /*input args*/\
|
||||
char *arglist[] /*output args*/\
|
||||
)\
|
||||
{\
|
||||
inT32 argcount; /*converted argc*/\
|
||||
int32_t argcount; /*converted argc*/\
|
||||
char *testchar; /*char in option string*/\
|
||||
inT32 arg; /*current argument*/\
|
||||
int32_t arg; /*current argument*/\
|
||||
\
|
||||
argcount=0; /*no of options*/\
|
||||
for (arg=0;arg<argc;arg++)\
|
||||
@ -80,17 +80,17 @@ char *arglist[] /*output args*/\
|
||||
return argcount; /*new number of args*/\
|
||||
}\
|
||||
\
|
||||
inT32 global_exit_code;\
|
||||
inT32 real_main(inT32,const char**);\
|
||||
int32_t global_exit_code;\
|
||||
int32_t real_main(int32_t,const char**);\
|
||||
\
|
||||
inT32 run_main( /*the main thread*/\
|
||||
int32_t run_main( /*the main thread*/\
|
||||
CWinApp* theapp /*arguments*/\
|
||||
)\
|
||||
{\
|
||||
char **argv;\
|
||||
char *argsin[2];\
|
||||
inT32 argc;\
|
||||
inT32 exit_code;\
|
||||
int32_t argc;\
|
||||
int32_t exit_code;\
|
||||
\
|
||||
argsin[0]=strdup(theapp->m_pszExeName);\
|
||||
argsin[1]=strdup(theapp->m_lpCmdLine);\
|
||||
@ -115,7 +115,7 @@ CWinApp* theapp /*arguments*/\
|
||||
return exit_code;\
|
||||
}\
|
||||
\
|
||||
inT32 real_main(inT32 ARGC,const char* ARGV[])\
|
||||
int32_t real_main(int32_t ARGC,const char* ARGV[])\
|
||||
|
||||
#else
|
||||
|
||||
@ -128,15 +128,15 @@ inT32 real_main(inT32 ARGC,const char* ARGV[])\
|
||||
* whitespace spaced string being an arg.\
|
||||
**********************************************************************/\
|
||||
\
|
||||
inT32 parse_args( /*refine arg list*/\
|
||||
inT32 argc, /*no of input args*/\
|
||||
int32_t parse_args( /*refine arg list*/\
|
||||
int32_t argc, /*no of input args*/\
|
||||
char *argv[], /*input args*/\
|
||||
char *arglist[] /*output args*/\
|
||||
)\
|
||||
{\
|
||||
inT32 argcount; /*converted argc*/\
|
||||
int32_t argcount; /*converted argc*/\
|
||||
char *testchar; /*char in option string*/\
|
||||
inT32 arg; /*current argument*/\
|
||||
int32_t arg; /*current argument*/\
|
||||
\
|
||||
argcount=0; /*no of options*/\
|
||||
for (arg=0;arg<argc;arg++)\
|
||||
@ -166,7 +166,7 @@ char *arglist[] /*output args*/\
|
||||
return argcount; /*new number of args*/\
|
||||
}\
|
||||
\
|
||||
inT32 main(inT32 ARGC,const char* ARGV[])\
|
||||
int32_t main(int32_t ARGC,const char* ARGV[])\
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace tesseract {
|
||||
bool ParamUtils::ReadParamsFile(const char *file,
|
||||
SetParamConstraint constraint,
|
||||
ParamsVectors *member_params) {
|
||||
inT16 nameoffset; // offset for real name
|
||||
int16_t nameoffset; // offset for real name
|
||||
|
||||
if (*file == PLUS) {
|
||||
nameoffset = 1;
|
||||
|
@ -76,9 +76,9 @@ class SortHelper {
|
||||
|
||||
// Returns the frequency of the most frequent value.
|
||||
// If max_value is not NULL, returns the most frequent value.
|
||||
// If the array is empty, returns -MAX_INT32 and max_value is unchanged.
|
||||
// If the array is empty, returns -INT32_MAX and max_value is unchanged.
|
||||
int MaxCount(T* max_value) const {
|
||||
int best_count = -MAX_INT32;
|
||||
int best_count = -INT32_MAX;
|
||||
for (int i = 0; i < counts_.size(); ++i) {
|
||||
if (counts_[i].count > best_count) {
|
||||
best_count = counts_[i].count;
|
||||
|
@ -381,7 +381,7 @@ STRING & STRING::operator+=(const STRING& str) {
|
||||
void STRING::add_str_int(const char* str, int number) {
|
||||
if (str != NULL)
|
||||
*this += str;
|
||||
// Allow space for the maximum possible length of inT64.
|
||||
// Allow space for the maximum possible length of int64_t.
|
||||
char num_buffer[kMaxIntSize];
|
||||
snprintf(num_buffer, kMaxIntSize - 1, "%d", number);
|
||||
num_buffer[kMaxIntSize - 1] = '\0';
|
||||
|
@ -57,20 +57,20 @@ bool TessdataManager::LoadMemBuffer(const char *name, const char *data,
|
||||
data_file_name_ = name;
|
||||
TFile fp;
|
||||
fp.Open(data, size);
|
||||
inT32 num_entries = TESSDATA_NUM_ENTRIES;
|
||||
int32_t num_entries = TESSDATA_NUM_ENTRIES;
|
||||
if (fp.FRead(&num_entries, sizeof(num_entries), 1) != 1) return false;
|
||||
swap_ = num_entries > kMaxNumTessdataEntries || num_entries < 0;
|
||||
fp.set_swap(swap_);
|
||||
if (swap_) ReverseN(&num_entries, sizeof(num_entries));
|
||||
if (num_entries > kMaxNumTessdataEntries || num_entries < 0) return false;
|
||||
GenericVector<inT64> offset_table;
|
||||
GenericVector<int64_t> offset_table;
|
||||
offset_table.resize_no_init(num_entries);
|
||||
if (fp.FReadEndian(&offset_table[0], sizeof(offset_table[0]), num_entries) !=
|
||||
num_entries)
|
||||
return false;
|
||||
for (int i = 0; i < num_entries && i < TESSDATA_NUM_ENTRIES; ++i) {
|
||||
if (offset_table[i] >= 0) {
|
||||
inT64 entry_size = size - offset_table[i];
|
||||
int64_t entry_size = size - offset_table[i];
|
||||
int j = i + 1;
|
||||
while (j < num_entries && offset_table[j] == -1) ++j;
|
||||
if (j < num_entries) entry_size = offset_table[j] - offset_table[i];
|
||||
@ -109,8 +109,8 @@ bool TessdataManager::SaveFile(const STRING &filename,
|
||||
void TessdataManager::Serialize(GenericVector<char> *data) const {
|
||||
ASSERT_HOST(is_loaded_);
|
||||
// Compute the offset_table and total size.
|
||||
inT64 offset_table[TESSDATA_NUM_ENTRIES];
|
||||
inT64 offset = sizeof(inT32) + sizeof(offset_table);
|
||||
int64_t offset_table[TESSDATA_NUM_ENTRIES];
|
||||
int64_t offset = sizeof(int32_t) + sizeof(offset_table);
|
||||
for (int i = 0; i < TESSDATA_NUM_ENTRIES; ++i) {
|
||||
if (entries_[i].empty()) {
|
||||
offset_table[i] = -1;
|
||||
@ -120,7 +120,7 @@ void TessdataManager::Serialize(GenericVector<char> *data) const {
|
||||
}
|
||||
}
|
||||
data->init_to_size(offset, 0);
|
||||
inT32 num_entries = TESSDATA_NUM_ENTRIES;
|
||||
int32_t num_entries = TESSDATA_NUM_ENTRIES;
|
||||
TFile fp;
|
||||
fp.OpenWrite(data);
|
||||
fp.FWrite(&num_entries, sizeof(num_entries), 1);
|
||||
@ -143,7 +143,7 @@ void TessdataManager::Clear() {
|
||||
// Prints a directory of contents.
|
||||
void TessdataManager::Directory() const {
|
||||
tprintf("Version string:%s\n", VersionString().c_str());
|
||||
int offset = TESSDATA_NUM_ENTRIES * sizeof(inT64);
|
||||
int offset = TESSDATA_NUM_ENTRIES * sizeof(int64_t);
|
||||
for (int i = 0; i < TESSDATA_NUM_ENTRIES; ++i) {
|
||||
if (!entries_[i].empty()) {
|
||||
tprintf("%d:%s:size=%d, offset=%d\n", i, kTessdataFileSuffixes[i],
|
||||
|
@ -43,7 +43,7 @@ tprintf_internal( // Trace printf
|
||||
va_list args; // variable args
|
||||
static FILE *debugfp = NULL; // debug file
|
||||
// debug window
|
||||
inT32 offset = 0; // into message
|
||||
int32_t offset = 0; // into message
|
||||
static char msg[MAX_MSG_LEN + 1];
|
||||
|
||||
va_start(args, format); // variable list
|
||||
|
@ -109,9 +109,9 @@ void UNICHARSET::UNICHAR_PROPERTIES::Init() {
|
||||
// no useful values available.
|
||||
void UNICHARSET::UNICHAR_PROPERTIES::SetRangesOpen() {
|
||||
min_bottom = 0;
|
||||
max_bottom = MAX_UINT8;
|
||||
max_bottom = UINT8_MAX;
|
||||
min_top = 0;
|
||||
max_top = MAX_UINT8;
|
||||
max_top = UINT8_MAX;
|
||||
width = 0.0f;
|
||||
width_sd = 0.0f;
|
||||
bearing = 0.0f;
|
||||
@ -122,9 +122,9 @@ void UNICHARSET::UNICHAR_PROPERTIES::SetRangesOpen() {
|
||||
|
||||
// Sets all ranges to empty. Used before expanding with font-based data.
|
||||
void UNICHARSET::UNICHAR_PROPERTIES::SetRangesEmpty() {
|
||||
min_bottom = MAX_UINT8;
|
||||
min_bottom = UINT8_MAX;
|
||||
max_bottom = 0;
|
||||
min_top = MAX_UINT8;
|
||||
min_top = UINT8_MAX;
|
||||
max_top = 0;
|
||||
width = 0.0f;
|
||||
width_sd = 0.0f;
|
||||
@ -805,9 +805,9 @@ bool UNICHARSET::load_via_fgets(
|
||||
|
||||
strcpy(script, null_script);
|
||||
int min_bottom = 0;
|
||||
int max_bottom = MAX_UINT8;
|
||||
int max_bottom = UINT8_MAX;
|
||||
int min_top = 0;
|
||||
int max_top = MAX_UINT8;
|
||||
int max_top = UINT8_MAX;
|
||||
float width = 0.0f;
|
||||
float width_sd = 0.0f;
|
||||
float bearing = 0.0f;
|
||||
@ -900,9 +900,9 @@ void UNICHARSET::post_load_setup() {
|
||||
top_bottom_set_ = false;
|
||||
for (UNICHAR_ID id = 0; id < size_used; ++id) {
|
||||
int min_bottom = 0;
|
||||
int max_bottom = MAX_UINT8;
|
||||
int max_bottom = UINT8_MAX;
|
||||
int min_top = 0;
|
||||
int max_top = MAX_UINT8;
|
||||
int max_top = UINT8_MAX;
|
||||
get_top_bottom(id, &min_bottom, &max_bottom, &min_top, &max_top);
|
||||
if (min_top > 0)
|
||||
top_bottom_set_ = true;
|
||||
|
@ -582,13 +582,13 @@ class UNICHARSET {
|
||||
int min_bottom, int max_bottom,
|
||||
int min_top, int max_top) {
|
||||
unichars[unichar_id].properties.min_bottom =
|
||||
static_cast<uint8_t>(ClipToRange(min_bottom, 0, MAX_UINT8));
|
||||
ClipToRange<int>(min_bottom, 0, UINT8_MAX);
|
||||
unichars[unichar_id].properties.max_bottom =
|
||||
static_cast<uint8_t>(ClipToRange(max_bottom, 0, MAX_UINT8));
|
||||
ClipToRange<int>(max_bottom, 0, UINT8_MAX);
|
||||
unichars[unichar_id].properties.min_top =
|
||||
static_cast<uint8_t>(ClipToRange(min_top, 0, MAX_UINT8));
|
||||
ClipToRange<int>(min_top, 0, UINT8_MAX);
|
||||
unichars[unichar_id].properties.max_top =
|
||||
static_cast<uint8_t>(ClipToRange(max_top, 0, MAX_UINT8));
|
||||
ClipToRange<int>(max_top, 0, UINT8_MAX);
|
||||
}
|
||||
// Returns the width stats (as mean, sd) of the given unichar relative to the
|
||||
// median advance of all characters in the character set.
|
||||
|
@ -185,7 +185,7 @@ ADAPT_TEMPLATES Classify::NewAdaptedTemplates(bool InitFromUnicharset) {
|
||||
} /* NewAdaptedTemplates */
|
||||
|
||||
// Returns FontinfoId of the given config of the given adapted class.
|
||||
int Classify::GetFontinfoId(ADAPT_CLASS Class, uinT8 ConfigId) {
|
||||
int Classify::GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId) {
|
||||
return (ConfigIsPermanent(Class, ConfigId) ?
|
||||
PermConfigFor(Class, ConfigId)->FontinfoId :
|
||||
TempConfigFor(Class, ConfigId)->FontinfoId);
|
||||
@ -316,9 +316,9 @@ ADAPT_CLASS ReadAdaptedClass(TFile *fp) {
|
||||
/* then read in the definitions of the permanent protos and configs */
|
||||
Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);
|
||||
Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);
|
||||
fp->FRead(Class->PermProtos, sizeof(uinT32),
|
||||
fp->FRead(Class->PermProtos, sizeof(uint32_t),
|
||||
WordsInVectorOfSize(MAX_NUM_PROTOS));
|
||||
fp->FRead(Class->PermConfigs, sizeof(uinT32),
|
||||
fp->FRead(Class->PermConfigs, sizeof(uint32_t),
|
||||
WordsInVectorOfSize(MAX_NUM_CONFIGS));
|
||||
|
||||
/* then read in the list of temporary protos */
|
||||
@ -391,8 +391,8 @@ ADAPT_TEMPLATES Classify::ReadAdaptedTemplates(TFile *fp) {
|
||||
*/
|
||||
PERM_CONFIG ReadPermConfig(TFile *fp) {
|
||||
PERM_CONFIG Config = (PERM_CONFIG)malloc(sizeof(PERM_CONFIG_STRUCT));
|
||||
uinT8 NumAmbigs;
|
||||
fp->FRead(&NumAmbigs, sizeof(uinT8), 1);
|
||||
uint8_t NumAmbigs;
|
||||
fp->FRead(&NumAmbigs, sizeof(NumAmbigs), 1);
|
||||
Config->Ambigs = new UNICHAR_ID[NumAmbigs + 1];
|
||||
fp->FRead(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs);
|
||||
Config->Ambigs[NumAmbigs] = -1;
|
||||
@ -420,7 +420,7 @@ TEMP_CONFIG ReadTempConfig(TFile *fp) {
|
||||
fp->FRead(Config, sizeof(TEMP_CONFIG_STRUCT), 1);
|
||||
|
||||
Config->Protos = NewBitVector (Config->ProtoVectorSize * BITSINLONG);
|
||||
fp->FRead(Config->Protos, sizeof(uinT32), Config->ProtoVectorSize);
|
||||
fp->FRead(Config->Protos, sizeof(uint32_t), Config->ProtoVectorSize);
|
||||
|
||||
return (Config);
|
||||
|
||||
@ -449,9 +449,9 @@ void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) {
|
||||
fwrite ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);
|
||||
|
||||
/* then write out the definitions of the permanent protos and configs */
|
||||
fwrite ((char *) Class->PermProtos, sizeof (uinT32),
|
||||
fwrite ((char *) Class->PermProtos, sizeof (uint32_t),
|
||||
WordsInVectorOfSize (MAX_NUM_PROTOS), File);
|
||||
fwrite ((char *) Class->PermConfigs, sizeof (uinT32),
|
||||
fwrite ((char *) Class->PermConfigs, sizeof (uint32_t),
|
||||
WordsInVectorOfSize (MAX_NUM_CONFIGS), File);
|
||||
|
||||
/* then write out the list of temporary protos */
|
||||
@ -517,12 +517,12 @@ void Classify::WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) {
|
||||
* @note History: Tue Mar 19 13:55:44 1991, DSJ, Created.
|
||||
*/
|
||||
void WritePermConfig(FILE *File, PERM_CONFIG Config) {
|
||||
uinT8 NumAmbigs = 0;
|
||||
uint8_t NumAmbigs = 0;
|
||||
|
||||
assert (Config != NULL);
|
||||
while (Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
|
||||
|
||||
fwrite((char *) &NumAmbigs, sizeof(uinT8), 1, File);
|
||||
fwrite((char *) &NumAmbigs, sizeof(uint8_t), 1, File);
|
||||
fwrite(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs, File);
|
||||
fwrite(&(Config->FontinfoId), sizeof(int), 1, File);
|
||||
} /* WritePermConfig */
|
||||
@ -544,7 +544,7 @@ void WriteTempConfig(FILE *File, TEMP_CONFIG Config) {
|
||||
assert (Config != NULL);
|
||||
|
||||
fwrite ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);
|
||||
fwrite ((char *) Config->Protos, sizeof (uinT32),
|
||||
fwrite ((char *) Config->Protos, sizeof (uint32_t),
|
||||
Config->ProtoVectorSize, File);
|
||||
|
||||
} /* WriteTempConfig */
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uinT16 ProtoId;
|
||||
uinT16 dummy;
|
||||
uint16_t ProtoId;
|
||||
uint16_t dummy;
|
||||
PROTO_STRUCT Proto;
|
||||
}
|
||||
|
||||
@ -38,8 +38,8 @@ typedef TEMP_PROTO_STRUCT *TEMP_PROTO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uinT8 NumTimesSeen;
|
||||
uinT8 ProtoVectorSize;
|
||||
uint8_t NumTimesSeen;
|
||||
uint8_t ProtoVectorSize;
|
||||
PROTO_ID MaxProtoId;
|
||||
BIT_VECTOR Protos;
|
||||
int FontinfoId; // font information inferred from pre-trained templates
|
||||
@ -61,9 +61,9 @@ typedef union
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uinT8 NumPermConfigs;
|
||||
uinT8 MaxNumTimesSeen; // maximum number of times any TEMP_CONFIG was seen
|
||||
uinT8 dummy[2]; // (cut at matcher_min_examples_for_prototyping)
|
||||
uint8_t NumPermConfigs;
|
||||
uint8_t MaxNumTimesSeen; // maximum number of times any TEMP_CONFIG was seen
|
||||
uint8_t dummy[2]; // (cut at matcher_min_examples_for_prototyping)
|
||||
BIT_VECTOR PermProtos;
|
||||
BIT_VECTOR PermConfigs;
|
||||
LIST TempProtos;
|
||||
@ -75,8 +75,8 @@ typedef struct
|
||||
{
|
||||
INT_TEMPLATES Templates;
|
||||
int NumNonEmptyClasses;
|
||||
uinT8 NumPermClasses;
|
||||
uinT8 dummy[3];
|
||||
uint8_t NumPermClasses;
|
||||
uint8_t dummy[3];
|
||||
ADAPT_CLASS Class[MAX_NUM_CLASSES];
|
||||
} ADAPT_TEMPLATES_STRUCT;
|
||||
typedef ADAPT_TEMPLATES_STRUCT *ADAPT_TEMPLATES;
|
||||
|
@ -80,7 +80,7 @@ using tesseract::UnicharRating;
|
||||
using tesseract::ScoredFont;
|
||||
|
||||
struct ADAPT_RESULTS {
|
||||
inT32 BlobLength;
|
||||
int32_t BlobLength;
|
||||
bool HasNonfragment;
|
||||
UNICHAR_ID best_unichar_id;
|
||||
int best_match_index;
|
||||
@ -91,7 +91,7 @@ struct ADAPT_RESULTS {
|
||||
/// Initializes data members to the default values. Sets the initial
|
||||
/// rating of each class to be the worst possible rating (1.0).
|
||||
inline void Initialize() {
|
||||
BlobLength = MAX_INT32;
|
||||
BlobLength = INT32_MAX;
|
||||
HasNonfragment = false;
|
||||
ComputeBest();
|
||||
}
|
||||
@ -979,7 +979,7 @@ void Classify::DisplayAdaptedChar(TBLOB* blob, INT_CLASS_STRUCT* int_class) {
|
||||
tprintf("Best match to temp config %d = %4.1f%%.\n",
|
||||
int_result.config, int_result.rating * 100.0);
|
||||
if (classify_learning_debug_level >= 2) {
|
||||
uinT32 ConfigMask;
|
||||
uint32_t ConfigMask;
|
||||
ConfigMask = 1 << int_result.config;
|
||||
ShowMatchDisplay();
|
||||
im_.Match(int_class, AllProtosOn, (BIT_VECTOR)&ConfigMask,
|
||||
@ -1076,7 +1076,7 @@ void Classify::AmbigClassifier(
|
||||
UNICHAR_ID *ambiguities,
|
||||
ADAPT_RESULTS *results) {
|
||||
if (int_features.empty()) return;
|
||||
uinT8* CharNormArray = new uinT8[unicharset.size()];
|
||||
uint8_t* CharNormArray = new uint8_t[unicharset.size()];
|
||||
UnicharRating int_result;
|
||||
|
||||
results->BlobLength = GetCharNormFeature(fx_info, templates, NULL,
|
||||
@ -1111,9 +1111,9 @@ void Classify::AmbigClassifier(
|
||||
/// Factored-out calls to IntegerMatcher based on class pruner results.
|
||||
/// Returns integer matcher results inside CLASS_PRUNER_RESULTS structure.
|
||||
void Classify::MasterMatcher(INT_TEMPLATES templates,
|
||||
inT16 num_features,
|
||||
int16_t num_features,
|
||||
const INT_FEATURE_STRUCT* features,
|
||||
const uinT8* norm_factors,
|
||||
const uint8_t* norm_factors,
|
||||
ADAPT_CLASS* classes,
|
||||
int debug,
|
||||
int matcher_multiplier,
|
||||
@ -1153,7 +1153,7 @@ void Classify::MasterMatcher(INT_TEMPLATES templates,
|
||||
void Classify::ExpandShapesAndApplyCorrections(
|
||||
ADAPT_CLASS* classes, bool debug, int class_id, int bottom, int top,
|
||||
float cp_rating, int blob_length, int matcher_multiplier,
|
||||
const uinT8* cn_factors,
|
||||
const uint8_t* cn_factors,
|
||||
UnicharRating* int_result, ADAPT_RESULTS* final_results) {
|
||||
if (classes != NULL) {
|
||||
// Adapted result. Convert configs to fontinfo_ids.
|
||||
@ -1229,7 +1229,7 @@ double Classify::ComputeCorrectedRating(bool debug, int unichar_id,
|
||||
int feature_misses,
|
||||
int bottom, int top,
|
||||
int blob_length, int matcher_multiplier,
|
||||
const uinT8* cn_factors) {
|
||||
const uint8_t* cn_factors) {
|
||||
// Compute class feature corrections.
|
||||
double cn_corrected = im_.ApplyCNCorrection(1.0 - im_rating, blob_length,
|
||||
cn_factors[unichar_id],
|
||||
@ -1294,7 +1294,7 @@ UNICHAR_ID *Classify::BaselineClassifier(
|
||||
const INT_FX_RESULT_STRUCT& fx_info,
|
||||
ADAPT_TEMPLATES Templates, ADAPT_RESULTS *Results) {
|
||||
if (int_features.empty()) return NULL;
|
||||
uinT8* CharNormArray = new uinT8[unicharset.size()];
|
||||
uint8_t* CharNormArray = new uint8_t[unicharset.size()];
|
||||
ClearCharNormArray(CharNormArray);
|
||||
|
||||
Results->BlobLength = IntCastRounded(fx_info.Length / kStandardFeatureLength);
|
||||
@ -1371,10 +1371,10 @@ int Classify::CharNormTrainingSample(bool pruner_only,
|
||||
sample.geo_feature(GeoTop), sample.geo_feature(GeoTop));
|
||||
// Compute the char_norm_array from the saved cn_feature.
|
||||
FEATURE norm_feature = sample.GetCNFeature();
|
||||
uinT8* char_norm_array = new uinT8[unicharset.size()];
|
||||
uint8_t* char_norm_array = new uint8_t[unicharset.size()];
|
||||
int num_pruner_classes = MAX(unicharset.size(),
|
||||
PreTrainedTemplates->NumClasses);
|
||||
uinT8* pruner_norm_array = new uinT8[num_pruner_classes];
|
||||
uint8_t* pruner_norm_array = new uint8_t[num_pruner_classes];
|
||||
adapt_results->BlobLength =
|
||||
static_cast<int>(ActualOutlineLength(norm_feature) * 20 + 0.5);
|
||||
ComputeCharNormArrays(norm_feature, PreTrainedTemplates, char_norm_array,
|
||||
@ -1713,8 +1713,8 @@ bool Classify::LooksLikeGarbage(TBLOB *blob) {
|
||||
*/
|
||||
int Classify::GetCharNormFeature(const INT_FX_RESULT_STRUCT& fx_info,
|
||||
INT_TEMPLATES templates,
|
||||
uinT8* pruner_norm_array,
|
||||
uinT8* char_norm_array) {
|
||||
uint8_t* pruner_norm_array,
|
||||
uint8_t* char_norm_array) {
|
||||
FEATURE norm_feature = NewFeature(&CharNormDesc);
|
||||
float baseline = kBlnBaselineOffset;
|
||||
float scale = MF_SCALE_FACTOR;
|
||||
@ -1733,14 +1733,14 @@ int Classify::GetCharNormFeature(const INT_FX_RESULT_STRUCT& fx_info,
|
||||
// pruner_array as appropriate according to the existence of the shape_table.
|
||||
void Classify::ComputeCharNormArrays(FEATURE_STRUCT* norm_feature,
|
||||
INT_TEMPLATES_STRUCT* templates,
|
||||
uinT8* char_norm_array,
|
||||
uinT8* pruner_array) {
|
||||
uint8_t* char_norm_array,
|
||||
uint8_t* pruner_array) {
|
||||
ComputeIntCharNormArray(*norm_feature, char_norm_array);
|
||||
if (pruner_array != NULL) {
|
||||
if (shape_table_ == NULL) {
|
||||
ComputeIntCharNormArray(*norm_feature, pruner_array);
|
||||
} else {
|
||||
memset(pruner_array, MAX_UINT8,
|
||||
memset(pruner_array, UINT8_MAX,
|
||||
templates->NumClasses * sizeof(pruner_array[0]));
|
||||
// Each entry in the pruner norm array is the MIN of all the entries of
|
||||
// the corresponding unichars in the CharNormArray.
|
||||
@ -2220,7 +2220,7 @@ void Classify::ShowBestMatchFor(int shape_id,
|
||||
const INT_FEATURE_STRUCT* features,
|
||||
int num_features) {
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
uinT32 config_mask;
|
||||
uint32_t config_mask;
|
||||
if (UnusedClassIdIn(PreTrainedTemplates, shape_id)) {
|
||||
tprintf("No built-in templates for class/shape %d\n", shape_id);
|
||||
return;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user