mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-06-07 09:52:40 +08:00
Fixed a lot of compiler/clang warnings
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1015 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
aa62157687
commit
d11dc049e3
@ -2282,7 +2282,6 @@ void TessBaseAPI::AdaptToCharacter(const char *unichar_repr,
|
|||||||
tesseract_->classify_bln_numeric_mode,
|
tesseract_->classify_bln_numeric_mode,
|
||||||
tesseract_->pix_binary());
|
tesseract_->pix_binary());
|
||||||
float threshold;
|
float threshold;
|
||||||
UNICHAR_ID best_class = 0;
|
|
||||||
float best_rating = -100;
|
float best_rating = -100;
|
||||||
|
|
||||||
|
|
||||||
@ -2295,7 +2294,6 @@ void TessBaseAPI::AdaptToCharacter(const char *unichar_repr,
|
|||||||
choice_it.forward()) {
|
choice_it.forward()) {
|
||||||
if (choice_it.data()->rating() > best_rating) {
|
if (choice_it.data()->rating() > best_rating) {
|
||||||
best_rating = choice_it.data()->rating();
|
best_rating = choice_it.data()->rating();
|
||||||
best_class = choice_it.data()->unichar_id();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ template <typename T> class GenericVector;
|
|||||||
class PAGE_RES;
|
class PAGE_RES;
|
||||||
class PAGE_RES_IT;
|
class PAGE_RES_IT;
|
||||||
class ParagraphModel;
|
class ParagraphModel;
|
||||||
class BlamerBundle;
|
struct BlamerBundle;
|
||||||
class BLOCK_LIST;
|
class BLOCK_LIST;
|
||||||
class DENORM;
|
class DENORM;
|
||||||
class IMAGE;
|
class IMAGE;
|
||||||
|
@ -177,12 +177,10 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *font_name;
|
|
||||||
bool bold, italic, underlined, monospace, serif, smallcaps;
|
bool bold, italic, underlined, monospace, serif, smallcaps;
|
||||||
int font_id;
|
int font_id;
|
||||||
font_name = res_it->WordFontAttributes(&bold, &italic, &underlined,
|
res_it->WordFontAttributes(&bold, &italic, &underlined, &monospace,
|
||||||
&monospace, &serif, &smallcaps,
|
&serif, &smallcaps, &pointsize, &font_id);
|
||||||
&pointsize, &font_id);
|
|
||||||
|
|
||||||
if (pointsize != old_pointsize) {
|
if (pointsize != old_pointsize) {
|
||||||
char textfont[20];
|
char textfont[20];
|
||||||
@ -209,7 +207,6 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
|
|||||||
old_y = y;
|
old_y = y;
|
||||||
|
|
||||||
bool last_word_in_line = res_it->IsAtFinalElement(RIL_TEXTLINE, RIL_WORD);
|
bool last_word_in_line = res_it->IsAtFinalElement(RIL_TEXTLINE, RIL_WORD);
|
||||||
bool last_word_in_para = res_it->IsAtFinalElement(RIL_PARA, RIL_WORD);
|
|
||||||
bool last_word_in_block = res_it->IsAtFinalElement(RIL_BLOCK, RIL_WORD);
|
bool last_word_in_block = res_it->IsAtFinalElement(RIL_BLOCK, RIL_WORD);
|
||||||
STRING pdf_word("");
|
STRING pdf_word("");
|
||||||
int pdf_word_len = 0;
|
int pdf_word_len = 0;
|
||||||
@ -221,7 +218,7 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
|
|||||||
string_32 utf32;
|
string_32 utf32;
|
||||||
CubeUtils::UTF8ToUTF32(grapheme, &utf32);
|
CubeUtils::UTF8ToUTF32(grapheme, &utf32);
|
||||||
char utf16[20];
|
char utf16[20];
|
||||||
for (int i = 0; i < utf32.length(); i++) {
|
for (int i = 0; i < static_cast<int>(utf32.length()); i++) {
|
||||||
snprintf(utf16, sizeof(utf16), "<%04X>", utf32[i]);
|
snprintf(utf16, sizeof(utf16), "<%04X>", utf32[i]);
|
||||||
pdf_word += utf16;
|
pdf_word += utf16;
|
||||||
pdf_word_len++;
|
pdf_word_len++;
|
||||||
@ -262,7 +259,6 @@ bool TessPDFRenderer::BeginDocumentHandler() {
|
|||||||
AppendPDFObject(buf);
|
AppendPDFObject(buf);
|
||||||
|
|
||||||
// CATALOG
|
// CATALOG
|
||||||
long int catalog = obj_;
|
|
||||||
snprintf(buf, sizeof(buf),
|
snprintf(buf, sizeof(buf),
|
||||||
"1 0 obj\n"
|
"1 0 obj\n"
|
||||||
"<<\n"
|
"<<\n"
|
||||||
@ -479,7 +475,8 @@ bool TessPDFRenderer::fileToPDFObj(char *filename, long int objnum,
|
|||||||
if (!pdf_object)
|
if (!pdf_object)
|
||||||
return false;
|
return false;
|
||||||
memcpy(*pdf_object, b1, b1_len);
|
memcpy(*pdf_object, b1, b1_len);
|
||||||
if (fread(*pdf_object + b1_len, 1, jpeg_size, fp) != jpeg_size) {
|
if (static_cast<int>(fread(*pdf_object + b1_len, 1, jpeg_size, fp)) !=
|
||||||
|
jpeg_size) {
|
||||||
delete[] pdf_object;
|
delete[] pdf_object;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,8 @@ int main(int argc, char **argv) {
|
|||||||
pixs = pixReadMem(&ch_data[0], ch_data.size());
|
pixs = pixReadMem(&ch_data[0], ch_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pagesegmode == tesseract::PSM_AUTO_OSD) {
|
if (pagesegmode == tesseract::PSM_AUTO_ONLY ||
|
||||||
|
pagesegmode == tesseract::PSM_OSD_ONLY) {
|
||||||
tesseract::Orientation orientation;
|
tesseract::Orientation orientation;
|
||||||
tesseract::WritingDirection direction;
|
tesseract::WritingDirection direction;
|
||||||
tesseract::TextlineOrder order;
|
tesseract::TextlineOrder order;
|
||||||
|
@ -331,7 +331,6 @@ bool LTRResultIterator::SymbolIsDropcap() const {
|
|||||||
ChoiceIterator::ChoiceIterator(const LTRResultIterator& result_it) {
|
ChoiceIterator::ChoiceIterator(const LTRResultIterator& result_it) {
|
||||||
ASSERT_HOST(result_it.it_->word() != NULL);
|
ASSERT_HOST(result_it.it_->word() != NULL);
|
||||||
word_res_ = result_it.it_->word();
|
word_res_ = result_it.it_->word();
|
||||||
PAGE_RES_IT res_it(*result_it.it_);
|
|
||||||
BLOB_CHOICE_LIST* choices = NULL;
|
BLOB_CHOICE_LIST* choices = NULL;
|
||||||
if (word_res_->ratings != NULL)
|
if (word_res_->ratings != NULL)
|
||||||
choices = word_res_->GetBlobChoices(result_it.blob_index_);
|
choices = word_res_->GetBlobChoices(result_it.blob_index_);
|
||||||
|
@ -395,10 +395,8 @@ bool OrientationDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
|
|||||||
float first = -1;
|
float first = -1;
|
||||||
float second = -1;
|
float second = -1;
|
||||||
|
|
||||||
int idx = -1;
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
if (osr_->orientations[i] > first) {
|
if (osr_->orientations[i] > first) {
|
||||||
idx = i;
|
|
||||||
second = first;
|
second = first;
|
||||||
first = osr_->orientations[i];
|
first = osr_->orientations[i];
|
||||||
} else if (osr_->orientations[i] > second) {
|
} else if (osr_->orientations[i] > second) {
|
||||||
@ -443,14 +441,9 @@ void ScriptDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
|
|||||||
float prev_score = -1;
|
float prev_score = -1;
|
||||||
int script_count = 0;
|
int script_count = 0;
|
||||||
int prev_id = -1;
|
int prev_id = -1;
|
||||||
int prev_script;
|
|
||||||
int prev_class_id = -1;
|
|
||||||
int prev_fontinfo_id = -1;
|
int prev_fontinfo_id = -1;
|
||||||
const char* prev_unichar = "";
|
const char* prev_unichar = "";
|
||||||
const char* unichar = "";
|
const char* unichar = "";
|
||||||
float next_best_score = -1.0;
|
|
||||||
int next_best_script_id = -1;
|
|
||||||
const char* next_best_unichar = "";
|
|
||||||
|
|
||||||
for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
|
for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
|
||||||
choice_it.forward()) {
|
choice_it.forward()) {
|
||||||
@ -466,15 +459,10 @@ void ScriptDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
|
|||||||
prev_score = -choice->certainty();
|
prev_score = -choice->certainty();
|
||||||
script_count = 1;
|
script_count = 1;
|
||||||
prev_id = id;
|
prev_id = id;
|
||||||
prev_script = choice->script_id();
|
|
||||||
prev_unichar = unichar;
|
prev_unichar = unichar;
|
||||||
prev_class_id = choice->unichar_id();
|
|
||||||
prev_fontinfo_id = choice->fontinfo_id();
|
prev_fontinfo_id = choice->fontinfo_id();
|
||||||
} else if (-choice->certainty() < prev_score + kNonAmbiguousMargin) {
|
} else if (-choice->certainty() < prev_score + kNonAmbiguousMargin) {
|
||||||
++script_count;
|
++script_count;
|
||||||
next_best_score = -choice->certainty();
|
|
||||||
next_best_script_id = choice->script_id();
|
|
||||||
next_best_unichar = tess_->unicharset.id_to_unichar(choice->unichar_id());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(prev_unichar) == 1)
|
if (strlen(prev_unichar) == 1)
|
||||||
|
@ -70,7 +70,6 @@ void Tesseract::output_pass( //Tess output pass //send to api
|
|||||||
PAGE_RES_IT &page_res_it,
|
PAGE_RES_IT &page_res_it,
|
||||||
const TBOX *target_word_box) {
|
const TBOX *target_word_box) {
|
||||||
BLOCK_RES *block_of_last_word;
|
BLOCK_RES *block_of_last_word;
|
||||||
inT16 block_id;
|
|
||||||
BOOL8 force_eol; //During output
|
BOOL8 force_eol; //During output
|
||||||
BLOCK *nextblock; //block of next word
|
BLOCK *nextblock; //block of next word
|
||||||
WERD *nextword; //next word
|
WERD *nextword; //next word
|
||||||
@ -95,7 +94,6 @@ void Tesseract::output_pass( //Tess output pass //send to api
|
|||||||
if (tessedit_write_block_separators &&
|
if (tessedit_write_block_separators &&
|
||||||
block_of_last_word != page_res_it.block ()) {
|
block_of_last_word != page_res_it.block ()) {
|
||||||
block_of_last_word = page_res_it.block ();
|
block_of_last_word = page_res_it.block ();
|
||||||
block_id = block_of_last_word->block->index();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
force_eol = (tessedit_write_block_separators &&
|
force_eol = (tessedit_write_block_separators &&
|
||||||
@ -137,18 +135,10 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
|
|||||||
BOOL8 force_eol) { // override tilde crunch?
|
BOOL8 force_eol) { // override tilde crunch?
|
||||||
WERD_RES *word = page_res_it.word();
|
WERD_RES *word = page_res_it.word();
|
||||||
const UNICHARSET &uchset = *word->uch_set;
|
const UNICHARSET &uchset = *word->uch_set;
|
||||||
STRING repetition_code;
|
|
||||||
const STRING *wordstr;
|
|
||||||
STRING wordstr_lengths;
|
|
||||||
int i;
|
int i;
|
||||||
char unrecognised = STRING (unrecognised_char)[0];
|
|
||||||
char ep_chars[32]; //Only for unlv_tilde_crunch
|
|
||||||
int ep_chars_index = 0;
|
|
||||||
char txt_chs[32]; //Only for unlv_tilde_crunch
|
|
||||||
char map_chs[32]; //Only for unlv_tilde_crunch
|
|
||||||
int txt_index = 0;
|
|
||||||
BOOL8 need_reject = FALSE;
|
BOOL8 need_reject = FALSE;
|
||||||
UNICHAR_ID space = uchset.unichar_to_id(" ");
|
UNICHAR_ID space = uchset.unichar_to_id(" ");
|
||||||
|
|
||||||
if ((word->unlv_crunch_mode != CR_NONE ||
|
if ((word->unlv_crunch_mode != CR_NONE ||
|
||||||
word->best_choice->length() == 0) &&
|
word->best_choice->length() == 0) &&
|
||||||
!tessedit_zero_kelvin_rejection && !tessedit_word_for_word) {
|
!tessedit_zero_kelvin_rejection && !tessedit_word_for_word) {
|
||||||
@ -162,10 +152,6 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
|
|||||||
(word->word->space () > 0) &&
|
(word->word->space () > 0) &&
|
||||||
!word->word->flag (W_FUZZY_NON) &&
|
!word->word->flag (W_FUZZY_NON) &&
|
||||||
!word->word->flag (W_FUZZY_SP)) {
|
!word->word->flag (W_FUZZY_SP)) {
|
||||||
// Write a space to separate from preceeding good text.
|
|
||||||
txt_chs[txt_index] = ' ';
|
|
||||||
map_chs[txt_index++] = '1';
|
|
||||||
ep_chars[ep_chars_index++] = ' ';
|
|
||||||
stats_.last_char_was_tilde = false;
|
stats_.last_char_was_tilde = false;
|
||||||
}
|
}
|
||||||
need_reject = TRUE;
|
need_reject = TRUE;
|
||||||
@ -174,50 +160,16 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
|
|||||||
(force_eol && stats_.write_results_empty_block)) {
|
(force_eol && stats_.write_results_empty_block)) {
|
||||||
/* Write a reject char - mark as rejected unless zero_rejection mode */
|
/* Write a reject char - mark as rejected unless zero_rejection mode */
|
||||||
stats_.last_char_was_tilde = TRUE;
|
stats_.last_char_was_tilde = TRUE;
|
||||||
txt_chs[txt_index] = unrecognised;
|
|
||||||
if (tessedit_zero_rejection || (suspect_level == 0)) {
|
|
||||||
map_chs[txt_index++] = '1';
|
|
||||||
ep_chars[ep_chars_index++] = unrecognised;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
map_chs[txt_index++] = '0';
|
|
||||||
/*
|
|
||||||
The ep_choice string is a faked reject to allow newdiff to sync the
|
|
||||||
.etx with the .txt and .map files.
|
|
||||||
*/
|
|
||||||
ep_chars[ep_chars_index++] = CTRL_INSET; // escape code
|
|
||||||
//dummy reject
|
|
||||||
ep_chars[ep_chars_index++] = 1;
|
|
||||||
//dummy reject
|
|
||||||
ep_chars[ep_chars_index++] = 1;
|
|
||||||
//type
|
|
||||||
ep_chars[ep_chars_index++] = 2;
|
|
||||||
//dummy reject
|
|
||||||
ep_chars[ep_chars_index++] = 1;
|
|
||||||
//dummy reject
|
|
||||||
ep_chars[ep_chars_index++] = 1;
|
|
||||||
}
|
|
||||||
stats_.tilde_crunch_written = true;
|
stats_.tilde_crunch_written = true;
|
||||||
stats_.last_char_was_newline = false;
|
stats_.last_char_was_newline = false;
|
||||||
stats_.write_results_empty_block = false;
|
stats_.write_results_empty_block = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((word->word->flag (W_EOL) && !stats_.last_char_was_newline) || force_eol) {
|
if ((word->word->flag (W_EOL) && !stats_.last_char_was_newline) || force_eol) {
|
||||||
/* Add a new line output */
|
|
||||||
txt_chs[txt_index] = '\n';
|
|
||||||
map_chs[txt_index++] = '\n';
|
|
||||||
//end line
|
|
||||||
ep_chars[ep_chars_index++] = newline_type;
|
|
||||||
|
|
||||||
//Cos of the real newline
|
|
||||||
stats_.tilde_crunch_written = false;
|
stats_.tilde_crunch_written = false;
|
||||||
stats_.last_char_was_newline = true;
|
stats_.last_char_was_newline = true;
|
||||||
stats_.last_char_was_tilde = false;
|
stats_.last_char_was_tilde = false;
|
||||||
}
|
}
|
||||||
txt_chs[txt_index] = '\0';
|
|
||||||
map_chs[txt_index] = '\0';
|
|
||||||
ep_chars[ep_chars_index] = '\0'; // terminate string
|
|
||||||
word->ep_choice = new WERD_CHOICE(ep_chars, uchset);
|
|
||||||
|
|
||||||
if (force_eol)
|
if (force_eol)
|
||||||
stats_.write_results_empty_block = true;
|
stats_.write_results_empty_block = true;
|
||||||
@ -266,13 +218,7 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
|
|||||||
word->best_choice->debug_string().string(),
|
word->best_choice->debug_string().string(),
|
||||||
dict_word(*(word->best_choice)));
|
dict_word(*(word->best_choice)));
|
||||||
}
|
}
|
||||||
if (word->word->flag (W_REP_CHAR) && tessedit_write_rep_codes) {
|
if (!word->word->flag (W_REP_CHAR) || !tessedit_write_rep_codes) {
|
||||||
repetition_code = "|^~R";
|
|
||||||
wordstr_lengths = "\001\001\001\001";
|
|
||||||
repetition_code += uchset.id_to_unichar(get_rep_char(word));
|
|
||||||
wordstr_lengths += strlen(uchset.id_to_unichar(get_rep_char(word)));
|
|
||||||
wordstr = &repetition_code;
|
|
||||||
} else {
|
|
||||||
if (tessedit_zero_rejection) {
|
if (tessedit_zero_rejection) {
|
||||||
/* OVERRIDE ALL REJECTION MECHANISMS - ONLY REJECT TESS FAILURES */
|
/* OVERRIDE ALL REJECTION MECHANISMS - ONLY REJECT TESS FAILURES */
|
||||||
for (i = 0; i < word->best_choice->length(); ++i) {
|
for (i = 0; i < word->best_choice->length(); ++i) {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "publictypes.h"
|
#include "publictypes.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
class BlamerBundle;
|
struct BlamerBundle;
|
||||||
class C_BLOB_IT;
|
class C_BLOB_IT;
|
||||||
class PAGE_RES;
|
class PAGE_RES;
|
||||||
class PAGE_RES_IT;
|
class PAGE_RES_IT;
|
||||||
|
@ -629,7 +629,6 @@ void Tesseract::flip_hyphens(WERD_RES *word_res) {
|
|||||||
|
|
||||||
int num_blobs = word_res->rebuild_word->NumBlobs();
|
int num_blobs = word_res->rebuild_word->NumBlobs();
|
||||||
UNICHAR_ID unichar_dash = word_res->uch_set->unichar_to_id("-");
|
UNICHAR_ID unichar_dash = word_res->uch_set->unichar_to_id("-");
|
||||||
bool modified = false;
|
|
||||||
for (i = 0; i < best_choice->length() && i < num_blobs; ++i) {
|
for (i = 0; i < best_choice->length() && i < num_blobs; ++i) {
|
||||||
TBLOB* blob = word_res->rebuild_word->blobs[i];
|
TBLOB* blob = word_res->rebuild_word->blobs[i];
|
||||||
out_box = blob->bounding_box();
|
out_box = blob->bounding_box();
|
||||||
@ -647,7 +646,6 @@ void Tesseract::flip_hyphens(WERD_RES *word_res) {
|
|||||||
word_res->uch_set->get_enabled(unichar_dash)) {
|
word_res->uch_set->get_enabled(unichar_dash)) {
|
||||||
/* Certain HYPHEN */
|
/* Certain HYPHEN */
|
||||||
best_choice->set_unichar_id(unichar_dash, i);
|
best_choice->set_unichar_id(unichar_dash, i);
|
||||||
modified = true;
|
|
||||||
if (word_res->reject_map[i].rejected())
|
if (word_res->reject_map[i].rejected())
|
||||||
word_res->reject_map[i].setrej_hyphen_accept();
|
word_res->reject_map[i].setrej_hyphen_accept();
|
||||||
}
|
}
|
||||||
@ -702,7 +700,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
|
|||||||
!word_res->uch_set->get_enabled(unichar_O)) {
|
!word_res->uch_set->get_enabled(unichar_O)) {
|
||||||
return; // 0 or O are not present/enabled in unicharset
|
return; // 0 or O are not present/enabled in unicharset
|
||||||
}
|
}
|
||||||
bool modified = false;
|
|
||||||
for (i = 1; i < best_choice->length(); ++i) {
|
for (i = 1; i < best_choice->length(); ++i) {
|
||||||
if (best_choice->unichar_id(i) == unichar_0 ||
|
if (best_choice->unichar_id(i) == unichar_0 ||
|
||||||
best_choice->unichar_id(i) == unichar_O) {
|
best_choice->unichar_id(i) == unichar_O) {
|
||||||
@ -711,7 +708,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
|
|||||||
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
||||||
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i+1))) {
|
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i+1))) {
|
||||||
best_choice->set_unichar_id(unichar_O, i);
|
best_choice->set_unichar_id(unichar_O, i);
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
/* A00A */
|
/* A00A */
|
||||||
if (non_O_upper(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
if (non_O_upper(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
||||||
@ -721,7 +717,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
|
|||||||
(i+2) < best_choice->length() &&
|
(i+2) < best_choice->length() &&
|
||||||
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i+2))) {
|
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i+2))) {
|
||||||
best_choice->set_unichar_id(unichar_O, i);
|
best_choice->set_unichar_id(unichar_O, i);
|
||||||
modified = true;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
/* AA0<non digit or end of word> */
|
/* AA0<non digit or end of word> */
|
||||||
@ -734,14 +729,12 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
|
|||||||
!word_res->uch_set->eq(best_choice->unichar_id(i+1), "I")) ||
|
!word_res->uch_set->eq(best_choice->unichar_id(i+1), "I")) ||
|
||||||
(i == best_choice->length() - 1))) {
|
(i == best_choice->length() - 1))) {
|
||||||
best_choice->set_unichar_id(unichar_O, i);
|
best_choice->set_unichar_id(unichar_O, i);
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
/* 9O9 */
|
/* 9O9 */
|
||||||
if (non_0_digit(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
if (non_0_digit(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
||||||
(i+1) < best_choice->length() &&
|
(i+1) < best_choice->length() &&
|
||||||
non_0_digit(*word_res->uch_set, best_choice->unichar_id(i+1))) {
|
non_0_digit(*word_res->uch_set, best_choice->unichar_id(i+1))) {
|
||||||
best_choice->set_unichar_id(unichar_0, i);
|
best_choice->set_unichar_id(unichar_0, i);
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
/* 9OOO */
|
/* 9OOO */
|
||||||
if (non_0_digit(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
if (non_0_digit(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
|
||||||
@ -753,7 +746,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
|
|||||||
best_choice->set_unichar_id(unichar_0, i);
|
best_choice->set_unichar_id(unichar_0, i);
|
||||||
best_choice->set_unichar_id(unichar_0, i+1);
|
best_choice->set_unichar_id(unichar_0, i+1);
|
||||||
best_choice->set_unichar_id(unichar_0, i+2);
|
best_choice->set_unichar_id(unichar_0, i+2);
|
||||||
modified = true;
|
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
/* 9OO<non upper> */
|
/* 9OO<non upper> */
|
||||||
@ -764,7 +756,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
|
|||||||
!word_res->uch_set->get_isupper(best_choice->unichar_id(i+2))) {
|
!word_res->uch_set->get_isupper(best_choice->unichar_id(i+2))) {
|
||||||
best_choice->set_unichar_id(unichar_0, i);
|
best_choice->set_unichar_id(unichar_0, i);
|
||||||
best_choice->set_unichar_id(unichar_0, i+1);
|
best_choice->set_unichar_id(unichar_0, i+1);
|
||||||
modified = true;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
/* 9O<non upper> */
|
/* 9O<non upper> */
|
||||||
@ -781,13 +772,11 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
|
|||||||
best_choice->unichar_id(i-2) == unichar_O)) {
|
best_choice->unichar_id(i-2) == unichar_O)) {
|
||||||
if (best_choice->unichar_id(i-2) == unichar_O) {
|
if (best_choice->unichar_id(i-2) == unichar_O) {
|
||||||
best_choice->set_unichar_id(unichar_0, i-2);
|
best_choice->set_unichar_id(unichar_0, i-2);
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
while (i < best_choice->length() &&
|
while (i < best_choice->length() &&
|
||||||
(best_choice->unichar_id(i) == unichar_O ||
|
(best_choice->unichar_id(i) == unichar_O ||
|
||||||
best_choice->unichar_id(i) == unichar_0)) {
|
best_choice->unichar_id(i) == unichar_0)) {
|
||||||
best_choice->set_unichar_id(unichar_0, i);
|
best_choice->set_unichar_id(unichar_0, i);
|
||||||
modified = true;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
|
@ -90,8 +90,8 @@ void Tesseract::recog_word(WERD_RES *word) {
|
|||||||
// Factored out from control.cpp
|
// Factored out from control.cpp
|
||||||
ASSERT_HOST((word->best_choice == NULL) == (word->raw_choice == NULL));
|
ASSERT_HOST((word->best_choice == NULL) == (word->raw_choice == NULL));
|
||||||
if (word->best_choice == NULL || word->best_choice->length() == 0 ||
|
if (word->best_choice == NULL || word->best_choice->length() == 0 ||
|
||||||
strspn(word->best_choice->unichar_string().string(), " ") ==
|
static_cast<int>(strspn(word->best_choice->unichar_string().string(),
|
||||||
word->best_choice->length()) {
|
" ")) == word->best_choice->length()) {
|
||||||
word->tess_failed = true;
|
word->tess_failed = true;
|
||||||
word->reject_map.initialise(word->box_word->length());
|
word->reject_map.initialise(word->box_word->length());
|
||||||
word->reject_map.rej_word_tess_failure();
|
word->reject_map.rej_word_tess_failure();
|
||||||
@ -145,8 +145,6 @@ void Tesseract::split_and_recog_word(WERD_RES *word) {
|
|||||||
// Find the biggest blob gap in the chopped_word.
|
// Find the biggest blob gap in the chopped_word.
|
||||||
int bestgap = -MAX_INT32;
|
int bestgap = -MAX_INT32;
|
||||||
int split_index = 0;
|
int split_index = 0;
|
||||||
TBLOB* best_end = NULL;
|
|
||||||
TBLOB* prev_blob = NULL;
|
|
||||||
for (int b = 1; b < word->chopped_word->NumBlobs(); ++b) {
|
for (int b = 1; b < word->chopped_word->NumBlobs(); ++b) {
|
||||||
TBOX prev_box = word->chopped_word->blobs[b - 1]->bounding_box();
|
TBOX prev_box = word->chopped_word->blobs[b - 1]->bounding_box();
|
||||||
TBOX blob_box = word->chopped_word->blobs[b]->bounding_box();
|
TBOX blob_box = word->chopped_word->blobs[b]->bounding_box();
|
||||||
|
@ -306,7 +306,6 @@ static TESSLINE** ApproximateOutlineList(bool allow_detailed_fx,
|
|||||||
// contain pointers to the input C_OUTLINEs that enable higher-resolution
|
// contain pointers to the input C_OUTLINEs that enable higher-resolution
|
||||||
// feature extraction that does not use the polygonal approximation.
|
// feature extraction that does not use the polygonal approximation.
|
||||||
TBLOB* TBLOB::PolygonalCopy(bool allow_detailed_fx, C_BLOB* src) {
|
TBLOB* TBLOB::PolygonalCopy(bool allow_detailed_fx, C_BLOB* src) {
|
||||||
C_OUTLINE_IT ol_it = src->out_list();
|
|
||||||
TBLOB* tblob = new TBLOB;
|
TBLOB* tblob = new TBLOB;
|
||||||
ApproximateOutlineList(allow_detailed_fx, src->out_list(), false,
|
ApproximateOutlineList(allow_detailed_fx, src->out_list(), false,
|
||||||
&tblob->outlines);
|
&tblob->outlines);
|
||||||
|
@ -156,7 +156,8 @@ bool read_info(FILE* f, FontInfo* fi, bool swap) {
|
|||||||
Reverse32(&size);
|
Reverse32(&size);
|
||||||
char* font_name = new char[size + 1];
|
char* font_name = new char[size + 1];
|
||||||
fi->name = font_name;
|
fi->name = font_name;
|
||||||
if (fread(font_name, sizeof(*font_name), size, f) != size) return false;
|
if (static_cast<int>(fread(font_name, sizeof(*font_name), size, f)) != size)
|
||||||
|
return false;
|
||||||
font_name[size] = '\0';
|
font_name[size] = '\0';
|
||||||
if (fread(&fi->properties, sizeof(fi->properties), 1, f) != 1) return false;
|
if (fread(&fi->properties, sizeof(fi->properties), 1, f) != 1) return false;
|
||||||
if (swap)
|
if (swap)
|
||||||
@ -167,7 +168,8 @@ bool read_info(FILE* f, FontInfo* fi, bool swap) {
|
|||||||
bool write_info(FILE* f, const FontInfo& fi) {
|
bool write_info(FILE* f, const FontInfo& fi) {
|
||||||
inT32 size = strlen(fi.name);
|
inT32 size = strlen(fi.name);
|
||||||
if (fwrite(&size, sizeof(size), 1, f) != 1) return false;
|
if (fwrite(&size, sizeof(size), 1, f) != 1) return false;
|
||||||
if (fwrite(fi.name, sizeof(*fi.name), size, f) != size) return false;
|
if (static_cast<int>(fwrite(fi.name, sizeof(*fi.name), size, f)) != size)
|
||||||
|
return false;
|
||||||
if (fwrite(&fi.properties, sizeof(fi.properties), 1, f) != 1) return false;
|
if (fwrite(&fi.properties, sizeof(fi.properties), 1, f) != 1) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ struct Pix;
|
|||||||
class ROW; // Forward decl
|
class ROW; // Forward decl
|
||||||
class BLOCK;
|
class BLOCK;
|
||||||
class FCOORD;
|
class FCOORD;
|
||||||
class TBLOB;
|
struct TBLOB;
|
||||||
class TBOX;
|
class TBOX;
|
||||||
class TPOINT;
|
struct TPOINT;
|
||||||
class UNICHARSET;
|
class UNICHARSET;
|
||||||
|
|
||||||
namespace tesseract {
|
namespace tesseract {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
class TO_ROW;
|
class TO_ROW;
|
||||||
|
|
||||||
class PARA;
|
struct PARA;
|
||||||
|
|
||||||
class ROW:public ELIST_LINK
|
class ROW:public ELIST_LINK
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "rect.h"
|
#include "rect.h"
|
||||||
|
|
||||||
class ROW;
|
class ROW;
|
||||||
class Pix;
|
struct Pix;
|
||||||
|
|
||||||
class QSPLINE
|
class QSPLINE
|
||||||
{
|
{
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include "werd.h"
|
#include "werd.h"
|
||||||
|
|
||||||
class MATRIX;
|
class MATRIX;
|
||||||
class TBLOB;
|
struct TBLOB;
|
||||||
class TWERD;
|
struct TWERD;
|
||||||
|
|
||||||
// Enum to describe the source of a BLOB_CHOICE to make it possible to determine
|
// Enum to describe the source of a BLOB_CHOICE to make it possible to determine
|
||||||
// whether a blob has been classified by inspecting the BLOB_CHOICEs.
|
// whether a blob has been classified by inspecting the BLOB_CHOICEs.
|
||||||
|
@ -193,10 +193,7 @@ bool test_insert_seam(const GenericVector<SEAM*>& seam_array,
|
|||||||
void insert_seam(const TWERD* word, int index, SEAM *seam,
|
void insert_seam(const TWERD* word, int index, SEAM *seam,
|
||||||
GenericVector<SEAM*>* seam_array) {
|
GenericVector<SEAM*>* seam_array) {
|
||||||
SEAM *test_seam;
|
SEAM *test_seam;
|
||||||
int test_index;
|
int list_length = seam_array->size();
|
||||||
int list_length;
|
|
||||||
|
|
||||||
list_length = seam_array->size();
|
|
||||||
for (int test_index = 0; test_index < index; ++test_index) {
|
for (int test_index = 0; test_index < index; ++test_index) {
|
||||||
test_seam = seam_array->get(test_index);
|
test_seam = seam_array->get(test_index);
|
||||||
if (test_index + test_seam->widthp >= index) {
|
if (test_index + test_seam->widthp >= index) {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "blobs.h"
|
#include "blobs.h"
|
||||||
|
|
||||||
class EDGEPT;
|
struct EDGEPT;
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
M a c r o s
|
M a c r o s
|
||||||
|
@ -465,7 +465,7 @@ WERD* WERD::ConstructWerdWithNewBlobs(C_BLOB_LIST* all_blobs,
|
|||||||
TBOX a_blob_box = a_blob->bounding_box();
|
TBOX a_blob_box = a_blob->bounding_box();
|
||||||
if ((not_found_box.major_overlap(a_blob_box) ||
|
if ((not_found_box.major_overlap(a_blob_box) ||
|
||||||
a_blob_box.major_overlap(not_found_box)) &&
|
a_blob_box.major_overlap(not_found_box)) &&
|
||||||
not_found_box.y_overlap(a_blob_box) > 0.8) {
|
not_found_box.y_overlap_fraction(a_blob_box) > 0.8) {
|
||||||
// Already taken care of.
|
// Already taken care of.
|
||||||
delete not_found_it.extract();
|
delete not_found_it.extract();
|
||||||
break;
|
break;
|
||||||
|
@ -138,7 +138,8 @@ void BitVector::Init(int length) {
|
|||||||
bool BitVector::Serialize(FILE* fp) const {
|
bool BitVector::Serialize(FILE* fp) const {
|
||||||
if (fwrite(&bit_size_, sizeof(bit_size_), 1, fp) != 1) return false;
|
if (fwrite(&bit_size_, sizeof(bit_size_), 1, fp) != 1) return false;
|
||||||
int wordlen = WordLength();
|
int wordlen = WordLength();
|
||||||
if (fwrite(array_, sizeof(*array_), wordlen, fp) != wordlen) return false;
|
if (static_cast<int>(fwrite(array_, sizeof(*array_), wordlen, fp)) != wordlen)
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +153,8 @@ bool BitVector::DeSerialize(bool swap, FILE* fp) {
|
|||||||
}
|
}
|
||||||
Alloc(new_bit_size);
|
Alloc(new_bit_size);
|
||||||
int wordlen = WordLength();
|
int wordlen = WordLength();
|
||||||
if (fread(array_, sizeof(*array_), wordlen, fp) != wordlen) return false;
|
if (static_cast<int>(fread(array_, sizeof(*array_), wordlen, fp)) != wordlen)
|
||||||
|
return false;
|
||||||
if (swap) {
|
if (swap) {
|
||||||
for (int i = 0; i < wordlen; ++i)
|
for (int i = 0; i < wordlen; ++i)
|
||||||
ReverseN(&array_[i], sizeof(array_[i]));
|
ReverseN(&array_[i], sizeof(array_[i]));
|
||||||
|
@ -129,7 +129,7 @@ class BitVector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Number of bits in this BitVector.
|
// Number of bits in this BitVector.
|
||||||
uinT32 bit_size_;
|
inT32 bit_size_;
|
||||||
// Array of words used to pack the bits.
|
// 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 word, ie by word first and then
|
||||||
// starting with the least significant bit in each word.
|
// starting with the least significant bit in each word.
|
||||||
|
@ -87,12 +87,21 @@ const ERRCODE ASSERT_FAILED = "Assert failed";
|
|||||||
__FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#define ASSERT_HOST_MSG(x, msg, ...) if (!(x)) \
|
#define ASSERT_HOST_MSG(x, msg, ...) if (!(x)) \
|
||||||
{ \
|
{ \
|
||||||
tprintf(msg); \
|
tprintf(msg); \
|
||||||
ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d", \
|
ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d", \
|
||||||
__FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define ASSERT_HOST_MSG(x, msg...) if (!(x)) \
|
||||||
|
{ \
|
||||||
|
tprintf(msg); \
|
||||||
|
ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d", \
|
||||||
|
__FILE__, __LINE__); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void signal_exit(int signal_code);
|
void signal_exit(int signal_code);
|
||||||
|
|
||||||
|
@ -346,7 +346,8 @@ inline bool SaveDataToFile(const GenericVector<char>& data,
|
|||||||
const STRING& filename) {
|
const STRING& filename) {
|
||||||
FILE* fp = fopen(filename.string(), "wb");
|
FILE* fp = fopen(filename.string(), "wb");
|
||||||
if (fp == NULL) return false;
|
if (fp == NULL) return false;
|
||||||
bool result = fwrite(&data[0], 1, data.size(), fp) == data.size();
|
bool result =
|
||||||
|
static_cast<int>(fwrite(&data[0], 1, data.size(), fp)) == data.size();
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ typedef unsigned char BOOL8;
|
|||||||
|
|
||||||
#define MIN_INT8 0x80
|
#define MIN_INT8 0x80
|
||||||
#define MIN_INT16 0x8000
|
#define MIN_INT16 0x8000
|
||||||
#define MIN_INT32 0x80000000
|
#define MIN_INT32 static_cast<int>(0x80000000)
|
||||||
#define MIN_UINT8 0x00
|
#define MIN_UINT8 0x00
|
||||||
#define MIN_UINT16 0x0000
|
#define MIN_UINT16 0x0000
|
||||||
#define MIN_UINT32 0x00000000
|
#define MIN_UINT32 0x00000000
|
||||||
|
@ -50,7 +50,7 @@ bool TFile::Open(FILE* fp, inT64 end_offset) {
|
|||||||
}
|
}
|
||||||
int size = end_offset - current_pos;
|
int size = end_offset - current_pos;
|
||||||
data_.init_to_size(size, 0);
|
data_.init_to_size(size, 0);
|
||||||
return fread(&data_[0], 1, size, fp) == size;
|
return static_cast<int>(fread(&data_[0], 1, size, fp)) == size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* TFile::FGets(char* buffer, int buffer_size) {
|
char* TFile::FGets(char* buffer, int buffer_size) {
|
||||||
|
@ -131,7 +131,7 @@ STRING::~STRING() {
|
|||||||
bool STRING::Serialize(FILE* fp) const {
|
bool STRING::Serialize(FILE* fp) const {
|
||||||
inT32 len = length();
|
inT32 len = length();
|
||||||
if (fwrite(&len, sizeof(len), 1, fp) != 1) return false;
|
if (fwrite(&len, sizeof(len), 1, fp) != 1) return false;
|
||||||
if (fwrite(GetCStr(), 1, len, fp) != len) return false;
|
if (static_cast<int>(fwrite(GetCStr(), 1, len, fp)) != len) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Reads from the given file. Returns false in case of error.
|
// Reads from the given file. Returns false in case of error.
|
||||||
@ -142,7 +142,7 @@ bool STRING::DeSerialize(bool swap, FILE* fp) {
|
|||||||
if (swap)
|
if (swap)
|
||||||
ReverseN(&len, sizeof(len));
|
ReverseN(&len, sizeof(len));
|
||||||
truncate_at(len);
|
truncate_at(len);
|
||||||
if (fread(GetCStr(), 1, len, fp) != len) return false;
|
if (static_cast<int>(fread(GetCStr(), 1, len, fp)) != len) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ AM_CPPFLAGS += -DTESS_EXPORTS \
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
adaptive.h blobclass.h chartoname.h \
|
adaptive.h blobclass.h \
|
||||||
classify.h cluster.h clusttool.h cutoffs.h \
|
classify.h cluster.h clusttool.h cutoffs.h \
|
||||||
errorcounter.h extern.h extract.h \
|
errorcounter.h extern.h extract.h \
|
||||||
featdefs.h flexfx.h float2int.h fpoint.h fxdefs.h \
|
featdefs.h flexfx.h float2int.h fpoint.h fxdefs.h \
|
||||||
@ -36,7 +36,7 @@ endif
|
|||||||
|
|
||||||
libtesseract_classify_la_SOURCES = \
|
libtesseract_classify_la_SOURCES = \
|
||||||
adaptive.cpp adaptmatch.cpp blobclass.cpp \
|
adaptive.cpp adaptmatch.cpp blobclass.cpp \
|
||||||
chartoname.cpp classify.cpp cluster.cpp clusttool.cpp cutoffs.cpp \
|
classify.cpp cluster.cpp clusttool.cpp cutoffs.cpp \
|
||||||
errorcounter.cpp extract.cpp \
|
errorcounter.cpp extract.cpp \
|
||||||
featdefs.cpp flexfx.cpp float2int.cpp fpoint.cpp fxdefs.cpp \
|
featdefs.cpp flexfx.cpp float2int.cpp fpoint.cpp fxdefs.cpp \
|
||||||
intfeaturedist.cpp intfeaturemap.cpp intfeaturespace.cpp \
|
intfeaturedist.cpp intfeaturemap.cpp intfeaturespace.cpp \
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "efio.h"
|
#include "efio.h"
|
||||||
#include "featdefs.h"
|
#include "featdefs.h"
|
||||||
#include "callcpp.h"
|
#include "callcpp.h"
|
||||||
#include "chartoname.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
/**************************************************************************
|
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
** you may not use this file except in compliance with the License.
|
|
||||||
** You may obtain a copy of the License at
|
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
** See the License for the specific language governing permissions and
|
|
||||||
** limitations under the License.
|
|
||||||
**************************************************************************/
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/*chartoname(name,c,dir) converts c into a useful filename*/
|
|
||||||
void chartoname(register char *name, /*result */
|
|
||||||
char c, /*char to convert */
|
|
||||||
const char *dir) { /*directory to use */
|
|
||||||
char file[3]; /*filename */
|
|
||||||
int index; /*index of namelist */
|
|
||||||
static const char *namelist[] = {
|
|
||||||
"!bang",
|
|
||||||
"\"doubleq",
|
|
||||||
"#hash",
|
|
||||||
"$dollar",
|
|
||||||
"%percent",
|
|
||||||
"&and",
|
|
||||||
"'quote",
|
|
||||||
"(lround",
|
|
||||||
")rround",
|
|
||||||
"*asterisk",
|
|
||||||
"+plus",
|
|
||||||
",comma",
|
|
||||||
"-minus",
|
|
||||||
".dot",
|
|
||||||
"/slash",
|
|
||||||
":colon",
|
|
||||||
";semic",
|
|
||||||
"<less",
|
|
||||||
"=equal",
|
|
||||||
">greater",
|
|
||||||
"?question",
|
|
||||||
"@at",
|
|
||||||
"[lsquare",
|
|
||||||
"\\backsl",
|
|
||||||
"]rsquare",
|
|
||||||
"^uparr",
|
|
||||||
"_unders",
|
|
||||||
"`grave",
|
|
||||||
"{lbrace",
|
|
||||||
"|bar",
|
|
||||||
"}rbrace",
|
|
||||||
"~tilde"
|
|
||||||
};
|
|
||||||
|
|
||||||
strcpy(name, dir); /*add specific directory */
|
|
||||||
for (index = 0; index < sizeof namelist / sizeof (char *)
|
|
||||||
&& c != namelist[index][0]; index++);
|
|
||||||
if (index < sizeof namelist / sizeof (char *))
|
|
||||||
/*add text name */
|
|
||||||
strcat (name, &namelist[index][1]);
|
|
||||||
else {
|
|
||||||
if (isupper (c)) {
|
|
||||||
file[0] = 'c'; /*direct a-z or A-Z */
|
|
||||||
file[1] = c; /*direct a-z or A-Z */
|
|
||||||
file[2] = '\0';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
file[0] = c; /*direct a-z or A-Z */
|
|
||||||
file[1] = '\0';
|
|
||||||
}
|
|
||||||
strcat(name, file); /*append filename */
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#ifndef CHARTONAME_H
|
|
||||||
#define CHARTONAME_H
|
|
||||||
|
|
||||||
/*result */
|
|
||||||
void chartoname(register char *name,
|
|
||||||
char c, /*char to convert */
|
|
||||||
const char *dir); /*directory to use */
|
|
||||||
|
|
||||||
/*
|
|
||||||
#if defined(__STDC__) || defined(__cplusplus)
|
|
||||||
# define _P(s) s
|
|
||||||
#else
|
|
||||||
# define _P(s) ()
|
|
||||||
#endif*/
|
|
||||||
|
|
||||||
/* chartoname.c
|
|
||||||
int chartoname _P((char *name, int c, char *dir));
|
|
||||||
|
|
||||||
#undef _P
|
|
||||||
*/
|
|
||||||
#endif
|
|
@ -30,7 +30,7 @@ class FontInfoTable;
|
|||||||
class SampleIterator;
|
class SampleIterator;
|
||||||
class ShapeClassifier;
|
class ShapeClassifier;
|
||||||
class TrainingSample;
|
class TrainingSample;
|
||||||
class UnicharRating;
|
struct UnicharRating;
|
||||||
|
|
||||||
// Enumeration of the different types of error count.
|
// Enumeration of the different types of error count.
|
||||||
// Error counts work as follows:
|
// Error counts work as follows:
|
||||||
|
@ -46,7 +46,7 @@ struct CHAR_DESC_STRUCT {
|
|||||||
typedef CHAR_DESC_STRUCT *CHAR_DESC;
|
typedef CHAR_DESC_STRUCT *CHAR_DESC;
|
||||||
|
|
||||||
struct FEATURE_DEFS_STRUCT {
|
struct FEATURE_DEFS_STRUCT {
|
||||||
uinT32 NumFeatureTypes;
|
inT32 NumFeatureTypes;
|
||||||
const FEATURE_DESC_STRUCT* FeatureDesc[NUM_FEATURE_TYPES];
|
const FEATURE_DESC_STRUCT* FeatureDesc[NUM_FEATURE_TYPES];
|
||||||
const FEATURE_EXT_STRUCT* FeatureExtractors[NUM_FEATURE_TYPES];
|
const FEATURE_EXT_STRUCT* FeatureExtractors[NUM_FEATURE_TYPES];
|
||||||
int FeatureEnabled[NUM_FEATURE_TYPES];
|
int FeatureEnabled[NUM_FEATURE_TYPES];
|
||||||
|
@ -41,7 +41,7 @@ class FCOORD;
|
|||||||
#define Y_SHIFT (0.5)
|
#define Y_SHIFT (0.5)
|
||||||
|
|
||||||
#define MAX_PROTO_INDEX 24
|
#define MAX_PROTO_INDEX 24
|
||||||
#define BITS_PER_WERD (8 * sizeof (uinT32))
|
#define BITS_PER_WERD static_cast<int>(8 * sizeof(uinT32))
|
||||||
/* Script detection: increase this number to 128 */
|
/* Script detection: increase this number to 128 */
|
||||||
#define MAX_NUM_CONFIGS 64
|
#define MAX_NUM_CONFIGS 64
|
||||||
#define MAX_NUM_PROTOS 512
|
#define MAX_NUM_PROTOS 512
|
||||||
|
@ -290,8 +290,6 @@ class MasterTrainer {
|
|||||||
bool enable_shape_anaylsis_;
|
bool enable_shape_anaylsis_;
|
||||||
// Flag to indicate that sample replication is required.
|
// Flag to indicate that sample replication is required.
|
||||||
bool enable_replication_;
|
bool enable_replication_;
|
||||||
// Flag to indicate that junk should be included in samples_.
|
|
||||||
bool include_junk_;
|
|
||||||
// Array of classids of fragments that replace the correctly segmented chars.
|
// Array of classids of fragments that replace the correctly segmented chars.
|
||||||
int* fragments_;
|
int* fragments_;
|
||||||
// Classid of previous correctly segmented sample that was added.
|
// Classid of previous correctly segmented sample that was added.
|
||||||
|
@ -24,7 +24,7 @@ class IntFeatureMap;
|
|||||||
class ShapeTable;
|
class ShapeTable;
|
||||||
class TrainingSample;
|
class TrainingSample;
|
||||||
class TrainingSampleSet;
|
class TrainingSampleSet;
|
||||||
class UnicharAndFonts;
|
struct UnicharAndFonts;
|
||||||
|
|
||||||
// Iterator class to encapsulate the complex iteration involved in getting
|
// Iterator class to encapsulate the complex iteration involved in getting
|
||||||
// all samples of all shapes needed for a classification problem.
|
// all samples of all shapes needed for a classification problem.
|
||||||
|
@ -61,10 +61,12 @@ bool TrainingSample::Serialize(FILE* fp) const {
|
|||||||
return false;
|
return false;
|
||||||
if (fwrite(&outline_length_, sizeof(outline_length_), 1, fp) != 1)
|
if (fwrite(&outline_length_, sizeof(outline_length_), 1, fp) != 1)
|
||||||
return false;
|
return false;
|
||||||
if (fwrite(features_, sizeof(*features_), num_features_, fp) != num_features_)
|
if (static_cast<int>(fwrite(features_, sizeof(*features_), num_features_, fp))
|
||||||
|
!= num_features_)
|
||||||
return false;
|
return false;
|
||||||
if (fwrite(micro_features_, sizeof(*micro_features_), num_micro_features_,
|
if (static_cast<int>(fwrite(micro_features_, sizeof(*micro_features_),
|
||||||
fp) != num_micro_features_)
|
num_micro_features_,
|
||||||
|
fp)) != num_micro_features_)
|
||||||
return false;
|
return false;
|
||||||
if (fwrite(cn_feature_, sizeof(*cn_feature_), kNumCNParams, fp) !=
|
if (fwrite(cn_feature_, sizeof(*cn_feature_), kNumCNParams, fp) !=
|
||||||
kNumCNParams) return false;
|
kNumCNParams) return false;
|
||||||
@ -102,12 +104,14 @@ bool TrainingSample::DeSerialize(bool swap, FILE* fp) {
|
|||||||
}
|
}
|
||||||
delete [] features_;
|
delete [] features_;
|
||||||
features_ = new INT_FEATURE_STRUCT[num_features_];
|
features_ = new INT_FEATURE_STRUCT[num_features_];
|
||||||
if (fread(features_, sizeof(*features_), num_features_, fp) != num_features_)
|
if (static_cast<int>(fread(features_, sizeof(*features_), num_features_, fp))
|
||||||
|
!= num_features_)
|
||||||
return false;
|
return false;
|
||||||
delete [] micro_features_;
|
delete [] micro_features_;
|
||||||
micro_features_ = new MicroFeature[num_micro_features_];
|
micro_features_ = new MicroFeature[num_micro_features_];
|
||||||
if (fread(micro_features_, sizeof(*micro_features_), num_micro_features_,
|
if (static_cast<int>(fread(micro_features_, sizeof(*micro_features_),
|
||||||
fp) != num_micro_features_)
|
num_micro_features_,
|
||||||
|
fp)) != num_micro_features_)
|
||||||
return false;
|
return false;
|
||||||
if (fread(cn_feature_, sizeof(*cn_feature_), kNumCNParams, fp) !=
|
if (fread(cn_feature_, sizeof(*cn_feature_), kNumCNParams, fp) !=
|
||||||
kNumCNParams) return false;
|
kNumCNParams) return false;
|
||||||
|
@ -32,7 +32,7 @@ class FontInfoTable;
|
|||||||
class IntFeatureMap;
|
class IntFeatureMap;
|
||||||
class IntFeatureSpace;
|
class IntFeatureSpace;
|
||||||
class TrainingSample;
|
class TrainingSample;
|
||||||
class UnicharAndFonts;
|
struct UnicharAndFonts;
|
||||||
|
|
||||||
// Collection of TrainingSample used for training or testing a classifier.
|
// Collection of TrainingSample used for training or testing a classifier.
|
||||||
// Provides several useful methods to operate on the collection as a whole,
|
// Provides several useful methods to operate on the collection as a whole,
|
||||||
|
@ -157,7 +157,6 @@ class CubeObject {
|
|||||||
CubeRecoContext *cntxt_;
|
CubeRecoContext *cntxt_;
|
||||||
BeamSearch *beam_obj_;
|
BeamSearch *beam_obj_;
|
||||||
BeamSearch *deslanted_beam_obj_;
|
BeamSearch *deslanted_beam_obj_;
|
||||||
bool offline_mode_;
|
|
||||||
bool own_char_samp_;
|
bool own_char_samp_;
|
||||||
bool deslanted_;
|
bool deslanted_;
|
||||||
CharSamp *char_samp_;
|
CharSamp *char_samp_;
|
||||||
|
@ -56,7 +56,6 @@ const int case_state_table[6][4] = { {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int Dict::case_ok(const WERD_CHOICE &word, const UNICHARSET &unicharset) {
|
int Dict::case_ok(const WERD_CHOICE &word, const UNICHARSET &unicharset) {
|
||||||
int last_state = 0;
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
int x;
|
int x;
|
||||||
for (x = 0; x < word.length(); ++x) {
|
for (x = 0; x < word.length(); ++x) {
|
||||||
@ -70,7 +69,6 @@ int Dict::case_ok(const WERD_CHOICE &word, const UNICHARSET &unicharset) {
|
|||||||
else
|
else
|
||||||
state = case_state_table[state][0];
|
state = case_state_table[state][0];
|
||||||
if (state == -1) return false;
|
if (state == -1) return false;
|
||||||
last_state = state;
|
|
||||||
}
|
}
|
||||||
return state != 5; // single lower is bad
|
return state != 5; // single lower is bad
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ NeuralNet::NeuralNet() {
|
|||||||
|
|
||||||
NeuralNet::~NeuralNet() {
|
NeuralNet::~NeuralNet() {
|
||||||
// clean up the wts chunks vector
|
// clean up the wts chunks vector
|
||||||
for(int vec = 0; vec < wts_vec_.size(); vec++) {
|
for (int vec = 0; vec < static_cast<int>(wts_vec_.size()); vec++) {
|
||||||
delete wts_vec_[vec];
|
delete wts_vec_[vec];
|
||||||
}
|
}
|
||||||
// clean up neurons
|
// clean up neurons
|
||||||
|
@ -30,7 +30,7 @@ class BLOBNBOX_LIST;
|
|||||||
class TO_BLOCK;
|
class TO_BLOCK;
|
||||||
class TO_BLOCK_LIST;
|
class TO_BLOCK_LIST;
|
||||||
class TO_ROW;
|
class TO_ROW;
|
||||||
class Pix;
|
struct Pix;
|
||||||
|
|
||||||
namespace tesseract {
|
namespace tesseract {
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ void ShiroRekhaSplitter::GetShiroRekhaYExtents(Pix* word_pix,
|
|||||||
int llimit = topline_ylevel;
|
int llimit = topline_ylevel;
|
||||||
while (ulimit > 0 && hist_horiz.hist()[ulimit] >= thresh)
|
while (ulimit > 0 && hist_horiz.hist()[ulimit] >= thresh)
|
||||||
--ulimit;
|
--ulimit;
|
||||||
while (llimit < word_pix->h && hist_horiz.hist()[llimit] >= thresh)
|
while (llimit < pixGetHeight(word_pix) && hist_horiz.hist()[llimit] >= thresh)
|
||||||
++llimit;
|
++llimit;
|
||||||
|
|
||||||
if (shirorekha_top) *shirorekha_top = ulimit;
|
if (shirorekha_top) *shirorekha_top = ulimit;
|
||||||
|
@ -69,7 +69,6 @@ ROW *fixed_pitch_words( //find lines
|
|||||||
WERD_IT rep_it = &row->rep_words;
|
WERD_IT rep_it = &row->rep_words;
|
||||||
WERD *word; //new word
|
WERD *word; //new word
|
||||||
inT32 xstarts[2]; //row ends
|
inT32 xstarts[2]; //row ends
|
||||||
double coeffs[3]; //quadratic
|
|
||||||
inT32 prev_x; //end of prev blob
|
inT32 prev_x; //end of prev blob
|
||||||
//iterator
|
//iterator
|
||||||
BLOBNBOX_IT box_it = row->blob_list ();
|
BLOBNBOX_IT box_it = row->blob_list ();
|
||||||
@ -190,9 +189,6 @@ ROW *fixed_pitch_words( //find lines
|
|||||||
if (prev_chop_coord > prev_x)
|
if (prev_chop_coord > prev_x)
|
||||||
prev_x = prev_chop_coord;
|
prev_x = prev_chop_coord;
|
||||||
xstarts[1] = prev_x + 1;
|
xstarts[1] = prev_x + 1;
|
||||||
coeffs[0] = 0;
|
|
||||||
coeffs[1] = row->line_m ();
|
|
||||||
coeffs[2] = row->line_c ();
|
|
||||||
real_row = new ROW (row, (inT16) row->kern_size, (inT16) row->space_size);
|
real_row = new ROW (row, (inT16) row->kern_size, (inT16) row->space_size);
|
||||||
word_it.set_to_list (real_row->word_list ());
|
word_it.set_to_list (real_row->word_list ());
|
||||||
//put words in row
|
//put words in row
|
||||||
@ -410,7 +406,6 @@ BOOL8 fixed_chop_coutline( //chop the outline
|
|||||||
C_OUTLINE_FRAG_LIST *right_frags //right half of chop
|
C_OUTLINE_FRAG_LIST *right_frags //right half of chop
|
||||||
) {
|
) {
|
||||||
BOOL8 first_frag; //fragment
|
BOOL8 first_frag; //fragment
|
||||||
BOOL8 anticlock; //direction of loop
|
|
||||||
inT16 left_edge; //of outline
|
inT16 left_edge; //of outline
|
||||||
inT16 startindex; //in first fragment
|
inT16 startindex; //in first fragment
|
||||||
inT32 length; //of outline
|
inT32 length; //of outline
|
||||||
@ -425,7 +420,6 @@ BOOL8 fixed_chop_coutline( //chop the outline
|
|||||||
|
|
||||||
length = srcline->pathlength ();
|
length = srcline->pathlength ();
|
||||||
pos = srcline->start_pos ();
|
pos = srcline->start_pos ();
|
||||||
anticlock = srcline->turn_direction () > 0;
|
|
||||||
left_edge = pos.x ();
|
left_edge = pos.x ();
|
||||||
tail_index = 0;
|
tail_index = 0;
|
||||||
tail_pos = pos;
|
tail_pos = pos;
|
||||||
|
@ -2079,7 +2079,6 @@ void Textord::make_spline_rows(TO_BLOCK *block, // block to do
|
|||||||
*/
|
*/
|
||||||
void make_baseline_spline(TO_ROW *row, //row to fit
|
void make_baseline_spline(TO_ROW *row, //row to fit
|
||||||
TO_BLOCK *block) {
|
TO_BLOCK *block) {
|
||||||
BLOBNBOX_IT blob_it = row->blob_list ();
|
|
||||||
inT32 *xstarts; // spline boundaries
|
inT32 *xstarts; // spline boundaries
|
||||||
double *coeffs; // quadratic coeffs
|
double *coeffs; // quadratic coeffs
|
||||||
inT32 segments; // no of segments
|
inT32 segments; // no of segments
|
||||||
|
@ -230,7 +230,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
|
|||||||
float descheight; /*mean descender drop */
|
float descheight; /*mean descender drop */
|
||||||
float mindescheight; /*min allowed descheight */
|
float mindescheight; /*min allowed descheight */
|
||||||
int desccount; /*no of samples */
|
int desccount; /*no of samples */
|
||||||
float xshift; /*shift in xheight */
|
|
||||||
|
|
||||||
/*no samples */
|
/*no samples */
|
||||||
xcount = fullcount = desccount = 0;
|
xcount = fullcount = desccount = 0;
|
||||||
@ -285,8 +284,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
|
|||||||
if (row->xheight >= lineheight * (1 - MAXHEIGHTVARIANCE)
|
if (row->xheight >= lineheight * (1 - MAXHEIGHTVARIANCE)
|
||||||
&& row->xheight <= lineheight * (1 + MAXHEIGHTVARIANCE)) {
|
&& row->xheight <= lineheight * (1 + MAXHEIGHTVARIANCE)) {
|
||||||
row->ascrise = fullheight - lineheight;
|
row->ascrise = fullheight - lineheight;
|
||||||
/*shift in x */
|
|
||||||
xshift = lineheight - row->xheight;
|
|
||||||
/*set to average */
|
/*set to average */
|
||||||
row->xheight = lineheight;
|
row->xheight = lineheight;
|
||||||
|
|
||||||
@ -294,7 +291,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
|
|||||||
else if (row->xheight >= fullheight * (1 - MAXHEIGHTVARIANCE)
|
else if (row->xheight >= fullheight * (1 - MAXHEIGHTVARIANCE)
|
||||||
&& row->xheight <= fullheight * (1 + MAXHEIGHTVARIANCE)) {
|
&& row->xheight <= fullheight * (1 + MAXHEIGHTVARIANCE)) {
|
||||||
row->ascrise = row->xheight - lineheight;
|
row->ascrise = row->xheight - lineheight;
|
||||||
xshift = -row->ascrise; /*shift in x */
|
|
||||||
/*set to average */
|
/*set to average */
|
||||||
row->xheight = lineheight;
|
row->xheight = lineheight;
|
||||||
row->all_caps = TRUE;
|
row->all_caps = TRUE;
|
||||||
@ -302,7 +298,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
|
|||||||
else {
|
else {
|
||||||
row->ascrise = (fullheight - lineheight) * row->xheight
|
row->ascrise = (fullheight - lineheight) * row->xheight
|
||||||
/ fullheight;
|
/ fullheight;
|
||||||
xshift = -row->ascrise; /*shift in x */
|
|
||||||
/*scale it */
|
/*scale it */
|
||||||
row->xheight -= row->ascrise;
|
row->xheight -= row->ascrise;
|
||||||
row->all_caps = TRUE;
|
row->all_caps = TRUE;
|
||||||
@ -1388,7 +1383,6 @@ int bestpart /*biggest partition */
|
|||||||
int poscount; /*count of best up step */
|
int poscount; /*count of best up step */
|
||||||
int negcount; /*count of best down step */
|
int negcount; /*count of best down step */
|
||||||
float partsteps[MAXPARTS]; /*average step to part */
|
float partsteps[MAXPARTS]; /*average step to part */
|
||||||
float bestpos; /*best up step */
|
|
||||||
float bestneg; /*best down step */
|
float bestneg; /*best down step */
|
||||||
int runlength; /*length of bad run */
|
int runlength; /*length of bad run */
|
||||||
int biggestrun; /*biggest bad run */
|
int biggestrun; /*biggest bad run */
|
||||||
@ -1400,12 +1394,14 @@ int bestpart /*biggest partition */
|
|||||||
xcentre = (blobcoords[blobindex].left ()
|
xcentre = (blobcoords[blobindex].left ()
|
||||||
+ blobcoords[blobindex].right ()) >> 1;
|
+ blobcoords[blobindex].right ()) >> 1;
|
||||||
/*in other parts */
|
/*in other parts */
|
||||||
if (partids[blobindex] != bestpart) {
|
int part_id =
|
||||||
|
static_cast<int>(static_cast<unsigned char>(partids[blobindex]));
|
||||||
|
if (part_id != bestpart) {
|
||||||
runlength++; /*run of non bests */
|
runlength++; /*run of non bests */
|
||||||
if (runlength > biggestrun)
|
if (runlength > biggestrun)
|
||||||
biggestrun = runlength;
|
biggestrun = runlength;
|
||||||
partsteps[partids[blobindex]] += blobcoords[blobindex].bottom ()
|
partsteps[part_id] += blobcoords[blobindex].bottom()
|
||||||
- row->baseline.y (xcentre);
|
- row->baseline.y(xcentre);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
runlength = 0;
|
runlength = 0;
|
||||||
@ -1415,7 +1411,7 @@ int bestpart /*biggest partition */
|
|||||||
else
|
else
|
||||||
row->xheight = 1.0f; /*success */
|
row->xheight = 1.0f; /*success */
|
||||||
poscount = negcount = 0;
|
poscount = negcount = 0;
|
||||||
bestpos = bestneg = 0.0; /*no step yet */
|
bestneg = 0.0; /*no step yet */
|
||||||
for (partition = 0; partition < partcount; partition++) {
|
for (partition = 0; partition < partcount; partition++) {
|
||||||
if (partition != bestpart) {
|
if (partition != bestpart) {
|
||||||
|
|
||||||
@ -1429,9 +1425,6 @@ int bestpart /*biggest partition */
|
|||||||
|
|
||||||
if (partsteps[partition] >= MINASCRISE
|
if (partsteps[partition] >= MINASCRISE
|
||||||
&& partsizes[partition] > poscount) {
|
&& partsizes[partition] > poscount) {
|
||||||
/*ascender rise */
|
|
||||||
bestpos = partsteps[partition];
|
|
||||||
/*2nd most popular */
|
|
||||||
poscount = partsizes[partition];
|
poscount = partsizes[partition];
|
||||||
}
|
}
|
||||||
if (partsteps[partition] <= -MINASCRISE
|
if (partsteps[partition] <= -MINASCRISE
|
||||||
|
@ -553,7 +553,6 @@ BOOL8 try_rows_fixed( //find line stats
|
|||||||
inT32 block_index, //block number
|
inT32 block_index, //block number
|
||||||
BOOL8 testing_on //correct orientation
|
BOOL8 testing_on //correct orientation
|
||||||
) {
|
) {
|
||||||
inT32 maxwidth; //of spaces
|
|
||||||
TO_ROW *row; //current row
|
TO_ROW *row; //current row
|
||||||
inT32 row_index; //row number.
|
inT32 row_index; //row number.
|
||||||
inT32 def_fixed = 0; //counters
|
inT32 def_fixed = 0; //counters
|
||||||
@ -570,7 +569,6 @@ BOOL8 try_rows_fixed( //find line stats
|
|||||||
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
|
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
|
||||||
row = row_it.data ();
|
row = row_it.data ();
|
||||||
ASSERT_HOST (row->xheight > 0);
|
ASSERT_HOST (row->xheight > 0);
|
||||||
maxwidth = (inT32) ceil (row->xheight * textord_words_maxspace);
|
|
||||||
if (row->fixed_pitch > 0 &&
|
if (row->fixed_pitch > 0 &&
|
||||||
fixed_pitch_row(row, block->block, block_index)) {
|
fixed_pitch_row(row, block->block, block_index)) {
|
||||||
if (row->fixed_pitch == 0) {
|
if (row->fixed_pitch == 0) {
|
||||||
|
@ -907,7 +907,6 @@ ROW *Textord::make_prop_words(
|
|||||||
inT32 next_rep_char_word_right = MAX_INT32;
|
inT32 next_rep_char_word_right = MAX_INT32;
|
||||||
float repetition_spacing; //gap between repetitions
|
float repetition_spacing; //gap between repetitions
|
||||||
inT32 xstarts[2]; //row ends
|
inT32 xstarts[2]; //row ends
|
||||||
double coeffs[3]; //quadratic
|
|
||||||
inT32 prev_x; //end of prev blob
|
inT32 prev_x; //end of prev blob
|
||||||
BLOBNBOX *bblob; //current blob
|
BLOBNBOX *bblob; //current blob
|
||||||
TBOX blob_box; //bounding box
|
TBOX blob_box; //bounding box
|
||||||
@ -1149,9 +1148,6 @@ ROW *Textord::make_prop_words(
|
|||||||
rep_char_it.forward ();
|
rep_char_it.forward ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
coeffs[0] = 0;
|
|
||||||
coeffs[1] = row->line_m ();
|
|
||||||
coeffs[2] = row->line_c ();
|
|
||||||
real_row = new ROW (row,
|
real_row = new ROW (row,
|
||||||
(inT16) row->kern_size, (inT16) row->space_size);
|
(inT16) row->kern_size, (inT16) row->space_size);
|
||||||
word_it.set_to_list (real_row->word_list ());
|
word_it.set_to_list (real_row->word_list ());
|
||||||
@ -1190,7 +1186,6 @@ ROW *Textord::make_blob_words(
|
|||||||
WERD_LIST words;
|
WERD_LIST words;
|
||||||
WERD_IT word_it; // new words
|
WERD_IT word_it; // new words
|
||||||
WERD *word; // new word
|
WERD *word; // new word
|
||||||
double coeffs[3]; // quadratic
|
|
||||||
BLOBNBOX *bblob; // current blob
|
BLOBNBOX *bblob; // current blob
|
||||||
TBOX blob_box; // bounding box
|
TBOX blob_box; // bounding box
|
||||||
BLOBNBOX_IT box_it; // iterator
|
BLOBNBOX_IT box_it; // iterator
|
||||||
@ -1235,9 +1230,6 @@ ROW *Textord::make_blob_words(
|
|||||||
}
|
}
|
||||||
while (!box_it.at_first()); // until back at start
|
while (!box_it.at_first()); // until back at start
|
||||||
/* Setup the row with created words. */
|
/* Setup the row with created words. */
|
||||||
coeffs[0] = 0;
|
|
||||||
coeffs[1] = row->line_m();
|
|
||||||
coeffs[2] = row->line_c();
|
|
||||||
real_row = new ROW(row, (inT16) row->kern_size, (inT16) row->space_size);
|
real_row = new ROW(row, (inT16) row->kern_size, (inT16) row->space_size);
|
||||||
word_it.set_to_list(real_row->word_list());
|
word_it.set_to_list(real_row->word_list());
|
||||||
//put words in row
|
//put words in row
|
||||||
|
@ -136,21 +136,14 @@ void set_row_spaces( //find space sizes
|
|||||||
FCOORD rotation, //for drawing
|
FCOORD rotation, //for drawing
|
||||||
BOOL8 testing_on //correct orientation
|
BOOL8 testing_on //correct orientation
|
||||||
) {
|
) {
|
||||||
inT32 maxwidth; //of widest space
|
|
||||||
TO_ROW *row; //current row
|
TO_ROW *row; //current row
|
||||||
TO_ROW_IT row_it = block->get_rows ();
|
TO_ROW_IT row_it = block->get_rows ();
|
||||||
|
|
||||||
if (row_it.empty ())
|
if (row_it.empty ())
|
||||||
return; //empty block
|
return; //empty block
|
||||||
maxwidth = (inT32) ceil (block->xheight * textord_words_maxspace);
|
|
||||||
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
|
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
|
||||||
row = row_it.data ();
|
row = row_it.data ();
|
||||||
if (row->fixed_pitch == 0) {
|
if (row->fixed_pitch == 0) {
|
||||||
// if (!textord_test_mode
|
|
||||||
// && row_words(block,row,maxwidth,rotation,testing_on)==0
|
|
||||||
// || textord_test_mode
|
|
||||||
// && row_words2(block,row,maxwidth,rotation,testing_on)==0)
|
|
||||||
// {
|
|
||||||
row->min_space =
|
row->min_space =
|
||||||
(inT32) ceil (row->pr_space -
|
(inT32) ceil (row->pr_space -
|
||||||
(row->pr_space -
|
(row->pr_space -
|
||||||
@ -166,7 +159,6 @@ void set_row_spaces( //find space sizes
|
|||||||
row->space_threshold = (row->max_nonspace + row->min_space) / 2;
|
row->space_threshold = (row->max_nonspace + row->min_space) / 2;
|
||||||
row->space_size = row->pr_space;
|
row->space_size = row->pr_space;
|
||||||
row->kern_size = row->pr_nonsp;
|
row->kern_size = row->pr_nonsp;
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
#ifndef GRAPHICS_DISABLED
|
#ifndef GRAPHICS_DISABLED
|
||||||
if (textord_show_initial_words && testing_on) {
|
if (textord_show_initial_words && testing_on) {
|
||||||
@ -572,10 +564,8 @@ ROW *make_rep_words( //make a row
|
|||||||
TO_ROW *row, //row to convert
|
TO_ROW *row, //row to convert
|
||||||
TO_BLOCK *block //block it lives in
|
TO_BLOCK *block //block it lives in
|
||||||
) {
|
) {
|
||||||
inT32 xstarts[2]; //ends of row
|
|
||||||
ROW *real_row; //output row
|
ROW *real_row; //output row
|
||||||
TBOX word_box; //bounding box
|
TBOX word_box; //bounding box
|
||||||
double coeffs[3]; //spline
|
|
||||||
//iterator
|
//iterator
|
||||||
WERD_IT word_it = &row->rep_words;
|
WERD_IT word_it = &row->rep_words;
|
||||||
|
|
||||||
@ -584,11 +574,6 @@ ROW *make_rep_words( //make a row
|
|||||||
word_box = word_it.data ()->bounding_box ();
|
word_box = word_it.data ()->bounding_box ();
|
||||||
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ())
|
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ())
|
||||||
word_box += word_it.data ()->bounding_box ();
|
word_box += word_it.data ()->bounding_box ();
|
||||||
xstarts[0] = word_box.left ();
|
|
||||||
xstarts[1] = word_box.right ();
|
|
||||||
coeffs[0] = 0;
|
|
||||||
coeffs[1] = row->line_m ();
|
|
||||||
coeffs[2] = row->line_c ();
|
|
||||||
row->xheight = block->xheight;
|
row->xheight = block->xheight;
|
||||||
real_row = new ROW(row,
|
real_row = new ROW(row,
|
||||||
(inT16) block->kern_size, (inT16) block->space_size);
|
(inT16) block->kern_size, (inT16) block->space_size);
|
||||||
|
@ -96,90 +96,90 @@ void* ScrollView::MessageReceiver(void* a) {
|
|||||||
// This is the main loop which iterates until the server is dead (strlen = -1).
|
// This is the main loop which iterates until the server is dead (strlen = -1).
|
||||||
// It basically parses for 3 different messagetypes and then distributes the
|
// It basically parses for 3 different messagetypes and then distributes the
|
||||||
// events accordingly.
|
// events accordingly.
|
||||||
while (strlen(message) != -1) {
|
while (1) {
|
||||||
// The new event we create.
|
// The new event we create.
|
||||||
SVEvent* cur = new SVEvent;
|
SVEvent* cur = new SVEvent;
|
||||||
// The ID of the corresponding window.
|
// The ID of the corresponding window.
|
||||||
int window_id;
|
int window_id;
|
||||||
|
|
||||||
int ev_type;
|
int ev_type;
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
// Fill the new SVEvent properly.
|
// Fill the new SVEvent properly.
|
||||||
sscanf(message, "%d,%d,%d,%d,%d,%d,%d,%n", &window_id, &ev_type, &cur->x,
|
sscanf(message, "%d,%d,%d,%d,%d,%d,%d,%n", &window_id, &ev_type, &cur->x,
|
||||||
&cur->y, &cur->x_size, &cur->y_size, &cur->command_id, &n);
|
&cur->y, &cur->x_size, &cur->y_size, &cur->command_id, &n);
|
||||||
char* p = (message + n);
|
char* p = (message + n);
|
||||||
|
|
||||||
svmap_mu->Lock();
|
svmap_mu->Lock();
|
||||||
cur->window = svmap[window_id];
|
cur->window = svmap[window_id];
|
||||||
|
|
||||||
if (cur->window != NULL) {
|
if (cur->window != NULL) {
|
||||||
cur->parameter = new char[strlen(p) + 1];
|
cur->parameter = new char[strlen(p) + 1];
|
||||||
strncpy(cur->parameter, p, strlen(p) + 1);
|
strncpy(cur->parameter, p, strlen(p) + 1);
|
||||||
if (strlen(p) > 0) { // remove the last \n
|
if (strlen(p) > 0) { // remove the last \n
|
||||||
cur->parameter[strlen(p)] = '\0';
|
cur->parameter[strlen(p)] = '\0';
|
||||||
}
|
|
||||||
cur->type = static_cast<SVEventType>(ev_type);
|
|
||||||
// Correct selection coordinates so x,y is the min pt and size is +ve.
|
|
||||||
if (cur->x_size > 0)
|
|
||||||
cur->x -= cur->x_size;
|
|
||||||
else
|
|
||||||
cur->x_size = -cur->x_size;
|
|
||||||
if (cur->y_size > 0)
|
|
||||||
cur->y -= cur->y_size;
|
|
||||||
else
|
|
||||||
cur->y_size = -cur->y_size;
|
|
||||||
// Returned y will be the bottom-left if y is reversed.
|
|
||||||
if (cur->window->y_axis_is_reversed_)
|
|
||||||
cur->y = cur->window->TranslateYCoordinate(cur->y + cur->y_size);
|
|
||||||
cur->counter = counter_event_id;
|
|
||||||
// Increase by 2 since we will also create an SVET_ANY event from cur,
|
|
||||||
// which will have a counter_id of cur + 1 (and thus gets processed
|
|
||||||
// after cur).
|
|
||||||
counter_event_id += 2;
|
|
||||||
|
|
||||||
// In case of an SVET_EXIT event, quit the whole application.
|
|
||||||
if (ev_type == SVET_EXIT) { ScrollView::Exit(); }
|
|
||||||
|
|
||||||
// Place two copies of it in the table for the window.
|
|
||||||
cur->window->SetEvent(cur);
|
|
||||||
|
|
||||||
// Check if any of the threads currently waiting want it.
|
|
||||||
std::pair<ScrollView*, SVEventType> awaiting_list(cur->window,
|
|
||||||
cur->type);
|
|
||||||
std::pair<ScrollView*, SVEventType> awaiting_list_any(cur->window,
|
|
||||||
SVET_ANY);
|
|
||||||
std::pair<ScrollView*, SVEventType> awaiting_list_any_window((ScrollView*)0,
|
|
||||||
SVET_ANY);
|
|
||||||
waiting_for_events_mu->Lock();
|
|
||||||
if (waiting_for_events.count(awaiting_list) > 0) {
|
|
||||||
waiting_for_events[awaiting_list].second = cur;
|
|
||||||
waiting_for_events[awaiting_list].first->Signal();
|
|
||||||
} else if (waiting_for_events.count(awaiting_list_any) > 0) {
|
|
||||||
waiting_for_events[awaiting_list_any].second = cur;
|
|
||||||
waiting_for_events[awaiting_list_any].first->Signal();
|
|
||||||
} else if (waiting_for_events.count(awaiting_list_any_window) > 0) {
|
|
||||||
waiting_for_events[awaiting_list_any_window].second = cur;
|
|
||||||
waiting_for_events[awaiting_list_any_window].first->Signal();
|
|
||||||
} else {
|
|
||||||
// No one wanted it, so delete it.
|
|
||||||
delete cur;
|
|
||||||
}
|
|
||||||
waiting_for_events_mu->Unlock();
|
|
||||||
// Signal the corresponding semaphore twice (for both copies).
|
|
||||||
ScrollView* sv = svmap[window_id];
|
|
||||||
if (sv != NULL) {
|
|
||||||
sv->Signal();
|
|
||||||
sv->Signal();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
svmap_mu->Unlock();
|
cur->type = static_cast<SVEventType>(ev_type);
|
||||||
|
// Correct selection coordinates so x,y is the min pt and size is +ve.
|
||||||
|
if (cur->x_size > 0)
|
||||||
|
cur->x -= cur->x_size;
|
||||||
|
else
|
||||||
|
cur->x_size = -cur->x_size;
|
||||||
|
if (cur->y_size > 0)
|
||||||
|
cur->y -= cur->y_size;
|
||||||
|
else
|
||||||
|
cur->y_size = -cur->y_size;
|
||||||
|
// Returned y will be the bottom-left if y is reversed.
|
||||||
|
if (cur->window->y_axis_is_reversed_)
|
||||||
|
cur->y = cur->window->TranslateYCoordinate(cur->y + cur->y_size);
|
||||||
|
cur->counter = counter_event_id;
|
||||||
|
// Increase by 2 since we will also create an SVET_ANY event from cur,
|
||||||
|
// which will have a counter_id of cur + 1 (and thus gets processed
|
||||||
|
// after cur).
|
||||||
|
counter_event_id += 2;
|
||||||
|
|
||||||
// Wait until a new message appears in the input stream_.
|
// In case of an SVET_EXIT event, quit the whole application.
|
||||||
do {
|
if (ev_type == SVET_EXIT) { ScrollView::Exit(); }
|
||||||
message = ScrollView::GetStream()->Receive();
|
|
||||||
} while (message == NULL);
|
// Place two copies of it in the table for the window.
|
||||||
|
cur->window->SetEvent(cur);
|
||||||
|
|
||||||
|
// Check if any of the threads currently waiting want it.
|
||||||
|
std::pair<ScrollView*, SVEventType> awaiting_list(cur->window,
|
||||||
|
cur->type);
|
||||||
|
std::pair<ScrollView*, SVEventType> awaiting_list_any(cur->window,
|
||||||
|
SVET_ANY);
|
||||||
|
std::pair<ScrollView*, SVEventType> awaiting_list_any_window((ScrollView*)0,
|
||||||
|
SVET_ANY);
|
||||||
|
waiting_for_events_mu->Lock();
|
||||||
|
if (waiting_for_events.count(awaiting_list) > 0) {
|
||||||
|
waiting_for_events[awaiting_list].second = cur;
|
||||||
|
waiting_for_events[awaiting_list].first->Signal();
|
||||||
|
} else if (waiting_for_events.count(awaiting_list_any) > 0) {
|
||||||
|
waiting_for_events[awaiting_list_any].second = cur;
|
||||||
|
waiting_for_events[awaiting_list_any].first->Signal();
|
||||||
|
} else if (waiting_for_events.count(awaiting_list_any_window) > 0) {
|
||||||
|
waiting_for_events[awaiting_list_any_window].second = cur;
|
||||||
|
waiting_for_events[awaiting_list_any_window].first->Signal();
|
||||||
|
} else {
|
||||||
|
// No one wanted it, so delete it.
|
||||||
|
delete cur;
|
||||||
|
}
|
||||||
|
waiting_for_events_mu->Unlock();
|
||||||
|
// Signal the corresponding semaphore twice (for both copies).
|
||||||
|
ScrollView* sv = svmap[window_id];
|
||||||
|
if (sv != NULL) {
|
||||||
|
sv->Signal();
|
||||||
|
sv->Signal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
svmap_mu->Unlock();
|
||||||
|
|
||||||
|
// Wait until a new message appears in the input stream_.
|
||||||
|
do {
|
||||||
|
message = ScrollView::GetStream()->Receive();
|
||||||
|
} while (message == NULL);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +396,6 @@ SEAM* Wordrec::chop_one_blob(const GenericVector<TBOX>& boxes,
|
|||||||
*/
|
*/
|
||||||
inT16 check_seam_order(TBLOB *blob, SEAM *seam) {
|
inT16 check_seam_order(TBLOB *blob, SEAM *seam) {
|
||||||
TESSLINE *outline;
|
TESSLINE *outline;
|
||||||
TESSLINE *last_outline;
|
|
||||||
inT8 found_em[3];
|
inT8 found_em[3];
|
||||||
|
|
||||||
if (seam->split1 == NULL || blob == NULL)
|
if (seam->split1 == NULL || blob == NULL)
|
||||||
@ -420,7 +419,6 @@ inT16 check_seam_order(TBLOB *blob, SEAM *seam) {
|
|||||||
is_split_outline (outline, seam->split3))) {
|
is_split_outline (outline, seam->split3))) {
|
||||||
found_em[2] = TRUE;
|
found_em[2] = TRUE;
|
||||||
}
|
}
|
||||||
last_outline = outline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found_em[0] || !found_em[1] || !found_em[2])
|
if (!found_em[0] || !found_em[1] || !found_em[2])
|
||||||
|
@ -155,12 +155,10 @@ void Wordrec::merge_and_put_fragment_lists(inT16 row, inT16 column,
|
|||||||
// Find the maximum unichar_id of the current entry the iterators
|
// Find the maximum unichar_id of the current entry the iterators
|
||||||
// are pointing at
|
// are pointing at
|
||||||
UNICHAR_ID max_unichar_id = choice_lists_it[0].data()->unichar_id();
|
UNICHAR_ID max_unichar_id = choice_lists_it[0].data()->unichar_id();
|
||||||
int max_list = 0;
|
|
||||||
for (int i = 0; i < num_frag_parts; i++) {
|
for (int i = 0; i < num_frag_parts; i++) {
|
||||||
UNICHAR_ID unichar_id = choice_lists_it[i].data()->unichar_id();
|
UNICHAR_ID unichar_id = choice_lists_it[i].data()->unichar_id();
|
||||||
if (max_unichar_id < unichar_id) {
|
if (max_unichar_id < unichar_id) {
|
||||||
max_unichar_id = unichar_id;
|
max_unichar_id = unichar_id;
|
||||||
max_list = i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user