Fixed issues 1093-1097

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1048 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
theraysmith@gmail.com 2014-02-04 23:36:24 +00:00
parent f01ea0e485
commit 7f5e5264d3
16 changed files with 37 additions and 81 deletions

View File

@ -34,7 +34,6 @@
#include "reject.h"
#include "control.h"
#include "stopper.h"
#include "secname.h"
#include "tesseractclass.h"
// Include automatically generated configuration file if running autoconf.

View File

@ -36,7 +36,6 @@
#include "fixspace.h"
#include "docqual.h"
#include "control.h"
#include "secname.h"
#include "output.h"
#include "callcpp.h"
#include "globals.h"
@ -1342,7 +1341,6 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
BOOL8 show_map_detail = FALSE;
inT16 i;
#ifndef SECURE_NAMES
if (!test_pt)
return FALSE;
@ -1413,10 +1411,9 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
tprintf ("Tess Accepted: %s\n", word->tess_accepted ? "TRUE" : "FALSE");
tprintf ("Done flag: %s\n\n", word->done ? "TRUE" : "FALSE");
return TRUE;
}
else
#endif
} else {
return FALSE;
}
}
/**

View File

@ -26,7 +26,6 @@
#include "reject.h"
#include "tesscallback.h"
#include "tessvars.h"
#include "secname.h"
#include "globals.h"
#include "tesseractclass.h"

View File

@ -27,7 +27,6 @@
#include "genblob.h"
#include "tessvars.h"
#include "tessbox.h"
#include "secname.h"
#include "globals.h"
#include "tesseractclass.h"
@ -465,7 +464,6 @@ void Tesseract::dump_words(WERD_RES_LIST &perm, inT16 score,
}
}
#ifndef SECURE_NAMES
if (debug_fix_space_level > 1) {
switch (mode) {
case 1:
@ -500,7 +498,6 @@ void Tesseract::dump_words(WERD_RES_LIST &perm, inT16 score,
}
tprintf("\"\n");
}
#endif
}
}

View File

@ -31,7 +31,6 @@
#include "helpers.h"
#include "tessvars.h"
#include "control.h"
#include "secname.h"
#include "reject.h"
#include "docqual.h"
#include "output.h"

View File

@ -34,13 +34,10 @@
#include "reject.h"
#include "control.h"
#include "docqual.h"
#include "secname.h"
#include "globaloc.h" // For err_exit.
#include "globals.h"
#include "helpers.h"
/* #define SECURE_NAMES done in secnames.h when necessary */
#include "tesseractclass.h"
// Include automatically generated configuration file if running autoconf.

View File

@ -19,7 +19,6 @@
#include "host.h"
#include "rejctmap.h"
#include "secname.h"
#include "params.h"
BOOL8 REJ::perm_rejected() { //Is char perm reject?
@ -233,8 +232,6 @@ void REJ::setrej_minimal_rej_accept() {
void REJ::full_print(FILE *fp) {
#ifndef SECURE_NAMES
fprintf (fp, "R_TESS_FAILURE: %s\n", flag (R_TESS_FAILURE) ? "T" : "F");
fprintf (fp, "R_SMALL_XHT: %s\n", flag (R_SMALL_XHT) ? "T" : "F");
fprintf (fp, "R_EDGE_CHAR: %s\n", flag (R_EDGE_CHAR) ? "T" : "F");
@ -265,7 +262,6 @@ void REJ::full_print(FILE *fp) {
fprintf (fp, "R_QUALITY_ACCEPT: %s\n", flag (R_QUALITY_ACCEPT) ? "T" : "F");
fprintf (fp, "R_MINIMAL_REJ_ACCEPT: %s\n",
flag (R_MINIMAL_REJ_ACCEPT) ? "T" : "F");
#endif
}

View File

@ -498,9 +498,15 @@ class PointerVector : public GenericVector<T*> {
T* item = NULL;
if (non_null) {
item = new T;
if (!item->DeSerialize(swap, fp)) return false;
if (!item->DeSerialize(swap, fp)) {
delete item;
return false;
}
this->push_back(item);
} else {
// Null elements should keep their place in the vector.
this->push_back(NULL);
}
this->push_back(item);
}
return true;
}

View File

@ -1,9 +1 @@
/* Include this file in any module which needs to have conditional compilation
of sensitive code for UNLV. In INTERNAL mode SECURE_NAMES is NOT defined.
For UNLV mode it IS defined, allowing multiple modules to do conditional
compilation on the same name.
*/
#ifndef SECURE_NAMES
/* #define SECURE_NAMES */
#endif
/* Redundant. Delete me. */

View File

@ -275,7 +275,6 @@ void Classify::PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) {
INT_CLASS IClass;
ADAPT_CLASS AClass;
#ifndef SECURE_NAMES
fprintf (File, "\n\nSUMMARY OF ADAPTED TEMPLATES:\n\n");
fprintf (File, "Num classes = %d; Num permanent classes = %d\n\n",
Templates->NumNonEmptyClasses, Templates->NumPermClasses);
@ -293,7 +292,6 @@ void Classify::PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) {
IClass->NumProtos - count (AClass->TempProtos));
}
}
#endif
fprintf (File, "\n");
} /* PrintAdaptedTemplates */

View File

@ -435,7 +435,6 @@ void Classify::EndAdaptiveClassifier() {
STRING Filename;
FILE *File;
#ifndef SECURE_NAMES
if (AdaptedTemplates != NULL &&
classify_enable_adaptive_matcher && classify_save_adapted_templates) {
Filename = imagefile + ADAPT_TEMPLATE_SUFFIX;
@ -450,7 +449,6 @@ void Classify::EndAdaptiveClassifier() {
fclose(File);
}
}
#endif
if (AdaptedTemplates != NULL) {
free_adapted_templates(AdaptedTemplates);
@ -567,11 +565,9 @@ void Classify::InitAdaptiveClassifier(bool load_pre_trained_templates) {
if (File == NULL) {
AdaptedTemplates = NewAdaptedTemplates(true);
} else {
#ifndef SECURE_NAMES
cprintf("\nReading pre-adapted templates from %s ...\n",
Filename.string());
fflush(stdout);
#endif
AdaptedTemplates = ReadAdaptedTemplates(File);
cprintf("\n");
fclose(File);

View File

@ -282,24 +282,25 @@ Return: Pointer to buffer holding floats or NULL if EOF
Exceptions: ILLEGALFLOAT
History: 6/6/89, DSJ, Created.
******************************************************************************/
FLOAT32 *
ReadNFloats (FILE * File, uinT16 N, FLOAT32 Buffer[]) {
FLOAT32* ReadNFloats(FILE * File, uinT16 N, FLOAT32 Buffer[]) {
int i;
int NumFloatsRead;
if (Buffer == NULL)
Buffer = (FLOAT32 *) Emalloc (N * sizeof (FLOAT32));
Buffer = reinterpret_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32)));
for (i = 0; i < N; i++) {
NumFloatsRead = fscanf (File, "%f", &(Buffer[i]));
NumFloatsRead = fscanf(File, "%f", &(Buffer[i]));
if (NumFloatsRead != 1) {
if ((NumFloatsRead == EOF) && (i == 0))
return (NULL);
else
DoError (ILLEGALFLOAT, "Illegal float specification");
if ((NumFloatsRead == EOF) && (i == 0)) {
Efree(Buffer);
return NULL;
} else {
DoError(ILLEGALFLOAT, "Illegal float specification");
}
}
}
return (Buffer);
return Buffer;
} // ReadNFloats

View File

@ -295,14 +295,11 @@ bool Bmp8::LoadFromCharDumpFile(FILE *fp) {
for (x = 0; x < wid_; x++, pix += 3) {
// for now we only support gray scale,
// so we expect R = G = B, it this is not the case, bail out
if ( buff[pix] != buff[pix + 1] ||
buff[pix] != buff[pix + 2]
) {
if (buff[pix] != buff[pix + 1] || buff[pix] != buff[pix + 2]) {
delete []buff;
return false;
}
line_buff_[y][x] = buff[pix];
}
line_buff_[y][x] = buff[pix];
}
}

View File

@ -201,6 +201,7 @@ CharSamp *CharSamp::FromCharDumpFile(FILE *fp) {
// read label
if (fread(label32, 1, val32 * sizeof(*label32), fp) !=
(val32 * sizeof(*label32))) {
delete [] label32;
return NULL;
}
// null terminate
@ -209,34 +210,22 @@ CharSamp *CharSamp::FromCharDumpFile(FILE *fp) {
label32 = NULL;
}
// read coordinates
if (fread(&page, 1, sizeof(page), fp) != sizeof(page)) {
return NULL;
}
if (fread(&left, 1, sizeof(left), fp) != sizeof(left)) {
return NULL;
}
if (fread(&top, 1, sizeof(top), fp) != sizeof(top)) {
return NULL;
}
if (fread(&first_char, 1, sizeof(first_char), fp) != sizeof(first_char)) {
return NULL;
}
if (fread(&last_char, 1, sizeof(last_char), fp) != sizeof(last_char)) {
return NULL;
}
if (fread(&norm_top, 1, sizeof(norm_top), fp) != sizeof(norm_top)) {
return NULL;
}
if (fread(&norm_bottom, 1, sizeof(norm_bottom), fp) != sizeof(norm_bottom)) {
return NULL;
}
if (fread(&norm_aspect_ratio, 1, sizeof(norm_aspect_ratio), fp) !=
sizeof(norm_aspect_ratio)) {
if (fread(&page, 1, sizeof(page), fp) != sizeof(page) ||
fread(&left, 1, sizeof(left), fp) != sizeof(left) ||
fread(&top, 1, sizeof(top), fp) != sizeof(top) ||
fread(&first_char, 1, sizeof(first_char), fp) != sizeof(first_char) ||
fread(&last_char, 1, sizeof(last_char), fp) != sizeof(last_char) ||
fread(&norm_top, 1, sizeof(norm_top), fp) != sizeof(norm_top) ||
fread(&norm_bottom, 1, sizeof(norm_bottom), fp) != sizeof(norm_bottom) ||
fread(&norm_aspect_ratio, 1, sizeof(norm_aspect_ratio), fp) !=
sizeof(norm_aspect_ratio)) {
delete [] label32;
return NULL;
}
// create the object
CharSamp *char_samp = new CharSamp();
if (char_samp == NULL) {
delete [] label32;
return NULL;
}
// init
@ -251,6 +240,7 @@ CharSamp *CharSamp::FromCharDumpFile(FILE *fp) {
char_samp->norm_aspect_ratio_ = norm_aspect_ratio;
// load the Bmp8 part
if (char_samp->LoadFromCharDumpFile(fp) == false) {
delete char_samp; // It owns label32.
return NULL;
}
return char_samp;

View File

@ -30,7 +30,6 @@
#include "tovars.h"
#include "wordseg.h"
#include "topitch.h"
#include "secname.h"
#include "helpers.h"
// Include automatically generated configuration file if running autoconf.
@ -251,13 +250,11 @@ void fix_row_pitch(TO_ROW *bad_row, // row to fix
}
else {
bad_row->pitch_decision = PITCH_CORR_PROP;
#ifndef SECURE_NAMES
if (block_votes == 0 && like_votes == 0 && other_votes > 0
&& (textord_debug_pitch_test || textord_debug_pitch_metric))
tprintf
("Warning:row %d of block %d set prop with no like rows against trend\n",
row_target, block_target);
#endif
}
}
if (textord_debug_pitch_metric) {

View File

@ -35,7 +35,6 @@
#include "wordseg.h"
#include "textord.h"
#include "tordmain.h"
#include "secname.h"
#include "allheaders.h"
@ -532,7 +531,6 @@ BOOL8 Textord::clean_noise_from_row( //remove empties
else if (blob_box.height () > row->x_height () * 2
&& (!word_it.at_first () || !blob_it.at_first ()))
dot_count += 2;
#ifndef SECURE_NAMES
if (testing_on) {
tprintf
("Blob at (%d,%d) -> (%d,%d), ols=%d, tc=%d, bldiff=%g\n",
@ -540,10 +538,8 @@ BOOL8 Textord::clean_noise_from_row( //remove empties
blob_box.top (), blob->out_list ()->length (), trans_count,
blob_box.bottom () - row->base_line (blob_box.left ()));
}
#endif
}
}
#ifndef SECURE_NAMES
if (textord_noise_debug) {
tprintf ("Row ending at (%d,%g):",
blob_box.right (), row->base_line (blob_box.right ()));
@ -553,7 +549,6 @@ BOOL8 Textord::clean_noise_from_row( //remove empties
dot_count > norm_count * textord_noise_normratio
&& dot_count > 2 ? "REJECTED" : "ACCEPTED");
}
#endif
return super_norm_count < textord_noise_sncount
&& dot_count > norm_count * textord_noise_rowratio && dot_count > 2;
}