mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-06-11 12:43:17 +08:00
show page 0 for multipage tiff;
Windows: use binary mode for fopen (issue 70); autotools: fixed cutil/Makefile.am, improved tessdata/Makefile.am; git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@604 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
4abdfdb8fe
commit
7ec3dca968
@ -440,7 +440,7 @@ Boxa* TessBaseAPI::GetComponentImages(PageIteratorLevel level,
|
|||||||
void TessBaseAPI::DumpPGM(const char* filename) {
|
void TessBaseAPI::DumpPGM(const char* filename) {
|
||||||
if (tesseract_ == NULL)
|
if (tesseract_ == NULL)
|
||||||
return;
|
return;
|
||||||
FILE *fp = fopen(filename, "w");
|
FILE *fp = fopen(filename, "wb");
|
||||||
Pix* pix = tesseract_->pix_binary();
|
Pix* pix = tesseract_->pix_binary();
|
||||||
int width = pixGetWidth(pix);
|
int width = pixGetWidth(pix);
|
||||||
int height = pixGetHeight(pix);
|
int height = pixGetHeight(pix);
|
||||||
@ -644,7 +644,7 @@ bool TessBaseAPI::ProcessPages(const char* filename,
|
|||||||
if (npages > 0) {
|
if (npages > 0) {
|
||||||
for (; page < npages && (pix = pixReadTiff(filename, page)) != NULL;
|
for (; page < npages && (pix = pixReadTiff(filename, page)) != NULL;
|
||||||
++page) {
|
++page) {
|
||||||
if (page > 0)
|
if (page >= 0)
|
||||||
tprintf(_("Page %d\n"), page);
|
tprintf(_("Page %d\n"), page);
|
||||||
char page_str[kMaxIntSize];
|
char page_str[kMaxIntSize];
|
||||||
snprintf(page_str, kMaxIntSize - 1, "%d", page);
|
snprintf(page_str, kMaxIntSize - 1, "%d", page);
|
||||||
@ -665,7 +665,7 @@ bool TessBaseAPI::ProcessPages(const char* filename,
|
|||||||
pixDestroy(&pix);
|
pixDestroy(&pix);
|
||||||
} else {
|
} else {
|
||||||
// The file is not an image file, so try it as a list of filenames.
|
// The file is not an image file, so try it as a list of filenames.
|
||||||
FILE* fimg = fopen(filename, "r");
|
FILE* fimg = fopen(filename, "rb");
|
||||||
if (fimg == NULL) {
|
if (fimg == NULL) {
|
||||||
tprintf(_("File %s cannot be opened!\n"), filename);
|
tprintf(_("File %s cannot be opened!\n"), filename);
|
||||||
return false;
|
return false;
|
||||||
@ -742,7 +742,7 @@ bool TessBaseAPI::ProcessPage(Pix* pix, int page_index, const char* filename,
|
|||||||
}
|
}
|
||||||
if (failed && retry_config != NULL && retry_config[0] != '\0') {
|
if (failed && retry_config != NULL && retry_config[0] != '\0') {
|
||||||
// Save current config variables before switching modes.
|
// Save current config variables before switching modes.
|
||||||
FILE* fp = fopen(kOldVarsFile, "w");
|
FILE* fp = fopen(kOldVarsFile, "wb");
|
||||||
PrintVariables(fp);
|
PrintVariables(fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
// Switch to alternate mode for retry.
|
// Switch to alternate mode for retry.
|
||||||
|
@ -110,7 +110,7 @@ int main(int argc, char **argv) {
|
|||||||
tesseract::TessBaseAPI::Version());
|
tesseract::TessBaseAPI::Version());
|
||||||
|
|
||||||
|
|
||||||
FILE* fin = fopen(image, "r");
|
FILE* fin = fopen(image, "rb");
|
||||||
if (fin == NULL) {
|
if (fin == NULL) {
|
||||||
printf("Cannot open input file: %s\n", image);
|
printf("Cannot open input file: %s\n", image);
|
||||||
exit(2);
|
exit(2);
|
||||||
@ -134,7 +134,7 @@ int main(int argc, char **argv) {
|
|||||||
api.GetBoolVariable("tessedit_create_boxfile", &output_box);
|
api.GetBoolVariable("tessedit_create_boxfile", &output_box);
|
||||||
STRING outfile = output;
|
STRING outfile = output;
|
||||||
outfile += output_hocr ? ".html" : output_box ? ".box" : ".txt";
|
outfile += output_hocr ? ".html" : output_box ? ".box" : ".txt";
|
||||||
FILE* fout = fopen(outfile.string(), "w");
|
FILE* fout = fopen(outfile.string(), "wb");
|
||||||
if (fout == NULL) {
|
if (fout == NULL) {
|
||||||
tprintf(_("Cannot create output file %s\n"), outfile.string());
|
tprintf(_("Cannot create output file %s\n"), outfile.string());
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -325,7 +325,7 @@ void ParamsEditor::WriteParams(char *filename,
|
|||||||
FILE *fp; // input file
|
FILE *fp; // input file
|
||||||
char msg_str[255];
|
char msg_str[255];
|
||||||
// if file exists
|
// if file exists
|
||||||
if ((fp = fopen (filename, "r")) != NULL) {
|
if ((fp = fopen (filename, "rb")) != NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
sprintf (msg_str, "Overwrite file " "%s" "? (Y/N)", filename);
|
sprintf (msg_str, "Overwrite file " "%s" "? (Y/N)", filename);
|
||||||
int a = sv_window_->ShowYesNoDialog(msg_str);
|
int a = sv_window_->ShowYesNoDialog(msg_str);
|
||||||
@ -333,7 +333,7 @@ void ParamsEditor::WriteParams(char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fp = fopen (filename, "w"); // can we write to it?
|
fp = fopen (filename, "wb"); // can we write to it?
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
sv_window_->AddMessage("Cant write to file " "%s" "", filename);
|
sv_window_->AddMessage("Cant write to file " "%s" "", filename);
|
||||||
return;
|
return;
|
||||||
|
@ -69,13 +69,13 @@ void Tesseract::read_config_file(const char *filename, bool init_only) {
|
|||||||
path += "configs/";
|
path += "configs/";
|
||||||
path += filename;
|
path += filename;
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
if ((fp = fopen(path.string(), "r")) != NULL) {
|
if ((fp = fopen(path.string(), "rb")) != NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
path = datadir;
|
path = datadir;
|
||||||
path += "tessconfigs/";
|
path += "tessconfigs/";
|
||||||
path += filename;
|
path += filename;
|
||||||
if ((fp = fopen(path.string(), "r")) != NULL) {
|
if ((fp = fopen(path.string(), "rb")) != NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
path = filename;
|
path = filename;
|
||||||
@ -148,7 +148,7 @@ bool Tesseract::init_tesseract_lang_data(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (((STRING &)tessedit_write_params_to_file).length() > 0) {
|
if (((STRING &)tessedit_write_params_to_file).length() > 0) {
|
||||||
FILE *params_file = fopen(tessedit_write_params_to_file.string(), "w");
|
FILE *params_file = fopen(tessedit_write_params_to_file.string(), "wb");
|
||||||
if (params_file != NULL) {
|
if (params_file != NULL) {
|
||||||
ParamUtils::PrintParams(params_file, this->params());
|
ParamUtils::PrintParams(params_file, this->params());
|
||||||
fclose(params_file);
|
fclose(params_file);
|
||||||
|
@ -57,7 +57,7 @@ bool TesseractCubeCombiner::LoadCombinerNet() {
|
|||||||
".tesseract_cube.nn";
|
".tesseract_cube.nn";
|
||||||
|
|
||||||
// Return false if file does not exist
|
// Return false if file does not exist
|
||||||
FILE *fp = fopen(net_file_name.c_str(), "r");
|
FILE *fp = fopen(net_file_name.c_str(), "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
|
@ -49,7 +49,7 @@ bool read_unlv_file( //print list of sides
|
|||||||
BLOCK_IT block_it = blocks; //block iterator
|
BLOCK_IT block_it = blocks; //block iterator
|
||||||
|
|
||||||
name += UNLV_EXT; //add extension
|
name += UNLV_EXT; //add extension
|
||||||
if ((pdfp = fopen (name.string (), "r")) == NULL) {
|
if ((pdfp = fopen (name.string (), "rb")) == NULL) {
|
||||||
return false; //didn't read one
|
return false; //didn't read one
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -35,7 +35,7 @@ FILE* OpenBoxFile(const STRING& fname) {
|
|||||||
|
|
||||||
filename += ".box";
|
filename += ".box";
|
||||||
FILE* box_file = NULL;
|
FILE* box_file = NULL;
|
||||||
if (!(box_file = fopen(filename.string(), "r"))) {
|
if (!(box_file = fopen(filename.string(), "rb"))) {
|
||||||
CANTOPENFILE.error("read_next_box", TESSEXIT,
|
CANTOPENFILE.error("read_next_box", TESSEXIT,
|
||||||
"Cant open box file %s",
|
"Cant open box file %s",
|
||||||
filename.string());
|
filename.string());
|
||||||
|
@ -58,7 +58,7 @@ bool ParamUtils::ReadParamsFile(const char *file, bool init_only,
|
|||||||
nameoffset = 0;
|
nameoffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen(file + nameoffset, "r");
|
fp = fopen(file + nameoffset, "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
tprintf("read_params_file: Can't open %s\n", file + nameoffset);
|
tprintf("read_params_file: Can't open %s\n", file + nameoffset);
|
||||||
return true;
|
return true;
|
||||||
|
@ -128,7 +128,8 @@ bool TessdataManager::CombineDataFiles(
|
|||||||
kTessdataFileSuffixes[i], &type, &text_file));
|
kTessdataFileSuffixes[i], &type, &text_file));
|
||||||
STRING filename = language_data_path_prefix;
|
STRING filename = language_data_path_prefix;
|
||||||
filename += kTessdataFileSuffixes[i];
|
filename += kTessdataFileSuffixes[i];
|
||||||
file_ptr[i] = fopen(filename.string(), text_file ? "r" : "rb");
|
// file_ptr[i] = fopen(filename.string(), text_file ? "r" : "rb");
|
||||||
|
file_ptr[i] = fopen(filename.string(), "rb");
|
||||||
if (file_ptr[i] != NULL) {
|
if (file_ptr[i] != NULL) {
|
||||||
offset_table[type] = ftell(output_file);
|
offset_table[type] = ftell(output_file);
|
||||||
CopyFile(file_ptr[i], output_file, text_file, -1);
|
CopyFile(file_ptr[i], output_file, text_file, -1);
|
||||||
@ -181,7 +182,8 @@ bool TessdataManager::OverwriteComponents(
|
|||||||
// Open the files with the new components.
|
// Open the files with the new components.
|
||||||
for (i = 0; i < num_new_components; ++i) {
|
for (i = 0; i < num_new_components; ++i) {
|
||||||
TessdataTypeFromFileName(component_filenames[i], &type, &text_file);
|
TessdataTypeFromFileName(component_filenames[i], &type, &text_file);
|
||||||
file_ptr[type] = fopen(component_filenames[i], text_file ? "r" : "rb");
|
// file_ptr[type] = fopen(component_filenames[i], text_file ? "r" : "rb");
|
||||||
|
file_ptr[type] = fopen(component_filenames[i], "rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write updated data to the output traineddata file.
|
// Write updated data to the output traineddata file.
|
||||||
|
@ -64,7 +64,7 @@ const char *format, ... //special message
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (debugfp == NULL && strlen (debug_file.string ()) > 0)
|
if (debugfp == NULL && strlen (debug_file.string ()) > 0)
|
||||||
debugfp = fopen (debug_file.string (), "w");
|
debugfp = fopen (debug_file.string (), "wb");
|
||||||
else if (debugfp != NULL && strlen (debug_file.string ()) == 0) {
|
else if (debugfp != NULL && strlen (debug_file.string ()) == 0) {
|
||||||
fclose(debugfp);
|
fclose(debugfp);
|
||||||
debugfp = NULL;
|
debugfp = NULL;
|
||||||
|
@ -226,7 +226,7 @@ class UNICHARSET {
|
|||||||
// Opens the file indicated by filename and saves unicharset to that file.
|
// Opens the file indicated by filename and saves unicharset to that file.
|
||||||
// Returns true if the operation is successful.
|
// Returns true if the operation is successful.
|
||||||
bool save_to_file(const char * const filename) const {
|
bool save_to_file(const char * const filename) const {
|
||||||
FILE* file = fopen(filename, "w+");
|
FILE* file = fopen(filename, "w+b");
|
||||||
if (file == NULL) return false;
|
if (file == NULL) return false;
|
||||||
bool result = save_to_file(file);
|
bool result = save_to_file(file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@ -241,7 +241,7 @@ class UNICHARSET {
|
|||||||
// from the given file. The previous data is lost.
|
// from the given file. The previous data is lost.
|
||||||
// Returns true if the operation is successful.
|
// Returns true if the operation is successful.
|
||||||
bool load_from_file(const char* const filename, bool skip_fragments) {
|
bool load_from_file(const char* const filename, bool skip_fragments) {
|
||||||
FILE* file = fopen(filename, "r");
|
FILE* file = fopen(filename, "rb");
|
||||||
if (file == NULL) return false;
|
if (file == NULL) return false;
|
||||||
bool result = load_from_file(file, skip_fragments);
|
bool result = load_from_file(file, skip_fragments);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -91,7 +91,7 @@ void LearnBlob(const FEATURE_DEFS_STRUCT &FeatureDefs, const STRING& filename,
|
|||||||
// the name of the file is the name of the image plus TRAIN_SUFFIX
|
// the name of the file is the name of the image plus TRAIN_SUFFIX
|
||||||
if (FeatureFile == NULL) {
|
if (FeatureFile == NULL) {
|
||||||
Filename += TRAIN_SUFFIX;
|
Filename += TRAIN_SUFFIX;
|
||||||
FeatureFile = Efopen(Filename.string(), "w");
|
FeatureFile = Efopen(Filename.string(), "wb");
|
||||||
cprintf("TRAINING ... Font name = %s\n", CurrFontName.string());
|
cprintf("TRAINING ... Font name = %s\n", CurrFontName.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,16 +78,16 @@ FEATURE_SET Classify::ExtractPicoFeatures(TBLOB *Blob) {
|
|||||||
iterate(RemainingOutlines) {
|
iterate(RemainingOutlines) {
|
||||||
Outline = (MFOUTLINE) first_node (RemainingOutlines);
|
Outline = (MFOUTLINE) first_node (RemainingOutlines);
|
||||||
/*---------Debug--------------------------------------------------*
|
/*---------Debug--------------------------------------------------*
|
||||||
OFile = fopen ("f:/ims/debug/pfOutline.logCPP", "r");
|
OFile = fopen ("f:/ims/debug/pfOutline.logCPP", "rb");
|
||||||
if (OFile == NULL)
|
if (OFile == NULL)
|
||||||
{
|
{
|
||||||
OFile = Efopen ("f:/ims/debug/pfOutline.logCPP", "w");
|
OFile = Efopen ("f:/ims/debug/pfOutline.logCPP", "wb");
|
||||||
WriteOutline(OFile, Outline);
|
WriteOutline(OFile, Outline);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose (OFile);
|
fclose (OFile);
|
||||||
OFile = Efopen ("f:/ims/debug/pfOutline.logCPP", "a");
|
OFile = Efopen ("f:/ims/debug/pfOutline.logCPP", "ab");
|
||||||
}
|
}
|
||||||
WriteOutline(OFile, Outline);
|
WriteOutline(OFile, Outline);
|
||||||
fclose (OFile);
|
fclose (OFile);
|
||||||
@ -97,16 +97,16 @@ FEATURE_SET Classify::ExtractPicoFeatures(TBLOB *Blob) {
|
|||||||
if (classify_norm_method == baseline)
|
if (classify_norm_method == baseline)
|
||||||
NormalizePicoX(FeatureSet);
|
NormalizePicoX(FeatureSet);
|
||||||
/*---------Debug--------------------------------------------------*
|
/*---------Debug--------------------------------------------------*
|
||||||
File = fopen ("f:/ims/debug/pfFeatSet.logCPP", "r");
|
File = fopen ("f:/ims/debug/pfFeatSet.logCPP", "rb");
|
||||||
if (File == NULL)
|
if (File == NULL)
|
||||||
{
|
{
|
||||||
File = Efopen ("f:/ims/debug/pfFeatSet.logCPP", "w");
|
File = Efopen ("f:/ims/debug/pfFeatSet.logCPP", "wb");
|
||||||
WriteFeatureSet(File, FeatureSet);
|
WriteFeatureSet(File, FeatureSet);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose (File);
|
fclose (File);
|
||||||
File = Efopen ("f:/ims/debug/pfFeatSet.logCPP", "a");
|
File = Efopen ("f:/ims/debug/pfFeatSet.logCPP", "ab");
|
||||||
}
|
}
|
||||||
WriteFeatureSet(File, FeatureSet);
|
WriteFeatureSet(File, FeatureSet);
|
||||||
fclose (File);
|
fclose (File);
|
||||||
|
@ -52,7 +52,7 @@ bool CachedFile::Open() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_ = fopen(file_name_.c_str(), "r");
|
fp_ = fopen(file_name_.c_str(), "rb");
|
||||||
if (fp_ == NULL) {
|
if (fp_ == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ CharSampSet * CharSampSet::FromCharDumpFile(string file_name) {
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
unsigned int val32;
|
unsigned int val32;
|
||||||
// open the file
|
// open the file
|
||||||
fp = fopen(file_name.c_str(), "r");
|
fp = fopen(file_name.c_str(), "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ FILE *CharSampSet::CreateCharDumpFile(string file_name) {
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
unsigned int val32;
|
unsigned int val32;
|
||||||
// create the file
|
// create the file
|
||||||
fp = fopen(file_name.c_str(), "w");
|
fp = fopen(file_name.c_str(), "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ bool ConvNetCharClassifier::LoadFoldingSets(const string &data_file_path,
|
|||||||
fold_file_name += ".cube.fold";
|
fold_file_name += ".cube.fold";
|
||||||
|
|
||||||
// folding sets are optional
|
// folding sets are optional
|
||||||
FILE *fp = fopen(fold_file_name.c_str(), "r");
|
FILE *fp = fopen(fold_file_name.c_str(), "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ bool ConvNetCharClassifier::LoadNets(const string &data_file_path,
|
|||||||
char_net_file += ".cube.nn";
|
char_net_file += ".cube.nn";
|
||||||
|
|
||||||
// neural network is optional
|
// neural network is optional
|
||||||
FILE *fp = fopen(char_net_file.c_str(), "r");
|
FILE *fp = fopen(char_net_file.c_str(), "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ bool CubeTuningParams::Load(string tuning_params_file) {
|
|||||||
|
|
||||||
// Save the parameters to a file
|
// Save the parameters to a file
|
||||||
bool CubeTuningParams::Save(string file_name) {
|
bool CubeTuningParams::Save(string file_name) {
|
||||||
FILE *params_file = fopen(file_name.c_str(), "w");
|
FILE *params_file = fopen(file_name.c_str(), "wb");
|
||||||
if (params_file == NULL) {
|
if (params_file == NULL) {
|
||||||
fprintf(stderr, "Cube ERROR (CubeTuningParams::Save): error opening file "
|
fprintf(stderr, "Cube ERROR (CubeTuningParams::Save): error opening file "
|
||||||
"%s for write.\n", file_name.c_str());
|
"%s for write.\n", file_name.c_str());
|
||||||
|
@ -267,7 +267,7 @@ unsigned char *CubeUtils::GetImageData(Pix *pix, int left, int top,
|
|||||||
// read file contents to a string
|
// read file contents to a string
|
||||||
bool CubeUtils::ReadFileToString(const string &file_name, string *str) {
|
bool CubeUtils::ReadFileToString(const string &file_name, string *str) {
|
||||||
str->clear();
|
str->clear();
|
||||||
FILE *fp = fopen(file_name.c_str(), "r");
|
FILE *fp = fopen(file_name.c_str(), "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ bool HybridNeuralNetCharClassifier::LoadFoldingSets(
|
|||||||
fold_file_name += ".cube.fold";
|
fold_file_name += ".cube.fold";
|
||||||
|
|
||||||
// folding sets are optional
|
// folding sets are optional
|
||||||
FILE *fp = fopen(fold_file_name.c_str(), "r");
|
FILE *fp = fopen(fold_file_name.c_str(), "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ bool HybridNeuralNetCharClassifier::LoadNets(const string &data_file_path,
|
|||||||
hybrid_net_file += ".cube.hybrid";
|
hybrid_net_file += ".cube.hybrid";
|
||||||
|
|
||||||
// neural network is optional
|
// neural network is optional
|
||||||
FILE *fp = fopen(hybrid_net_file.c_str(), "r");
|
FILE *fp = fopen(hybrid_net_file.c_str(), "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
SUBDIRS =
|
SUBDIRS =
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/ccutil
|
AM_CPPFLAGS = -I$(top_srcdir)/ccutil -I$(top_srcdir)/viewer
|
||||||
|
|
||||||
include_HEADERS = \
|
include_HEADERS = \
|
||||||
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h efio.h \
|
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h efio.h \
|
||||||
|
@ -92,7 +92,7 @@ FILE *open_file(const char *filename, const char *mode) {
|
|||||||
bool exists_file(const char *filename) {
|
bool exists_file(const char *filename) {
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
if ((f = fopen(filename, "r")) != NULL) {
|
if ((f = fopen(filename, "rb")) != NULL) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
|
@ -1,65 +1,6 @@
|
|||||||
datadir = @datadir@/tessdata
|
datadir = @datadir@/tessdata
|
||||||
data_DATA = ara.cube.bigrams \
|
data_DATA = *.traineddata \
|
||||||
ara.cube.fold \
|
*.cube.*
|
||||||
ara.cube.lm \
|
|
||||||
ara.cube.nn \
|
|
||||||
ara.cube.params \
|
|
||||||
ara.cube.size \
|
|
||||||
ara.cube.word-freq \
|
|
||||||
ara.traineddata \
|
|
||||||
eng.cube.bigrams \
|
|
||||||
eng.cube.lm \
|
|
||||||
eng.cube.params \
|
|
||||||
eng.cube.word-freq \
|
|
||||||
eng.traineddata \
|
|
||||||
eng.cube.fold \
|
|
||||||
eng.cube.nn \
|
|
||||||
eng.cube.size \
|
|
||||||
eng.tesseract_cube.nn \
|
|
||||||
bul.traineddata \
|
|
||||||
cat.traineddata \
|
|
||||||
ces.traineddata \
|
|
||||||
chi_sim.traineddata \
|
|
||||||
chi_tra.traineddata \
|
|
||||||
dan.traineddata \
|
|
||||||
dan-frak.traineddata \
|
|
||||||
deu.traineddata \
|
|
||||||
ell.traineddata \
|
|
||||||
fin.traineddata \
|
|
||||||
fra.traineddata \
|
|
||||||
heb.traineddata \
|
|
||||||
hin.cube.bigrams \
|
|
||||||
hin.cube.lm \
|
|
||||||
hin.cube.params \
|
|
||||||
hin.cube.word-freq \
|
|
||||||
hin.tesseract_cube.nn \
|
|
||||||
hin.traineddata \
|
|
||||||
hrv.traineddata \
|
|
||||||
hun.traineddata \
|
|
||||||
ind.traineddata \
|
|
||||||
ita.traineddata \
|
|
||||||
jpn.traineddata \
|
|
||||||
kor.traineddata \
|
|
||||||
lav.traineddata \
|
|
||||||
lit.traineddata \
|
|
||||||
nld.traineddata \
|
|
||||||
nor.traineddata \
|
|
||||||
osd.traineddata \
|
|
||||||
pol.traineddata \
|
|
||||||
por.traineddata \
|
|
||||||
ron.traineddata \
|
|
||||||
rus.traineddata \
|
|
||||||
slk.traineddata \
|
|
||||||
slk-frak.traineddata \
|
|
||||||
slv.traineddata \
|
|
||||||
spa.traineddata \
|
|
||||||
srp.traineddata \
|
|
||||||
swe.traineddata \
|
|
||||||
tgl.traineddata \
|
|
||||||
tha.traineddata \
|
|
||||||
tur.traineddata \
|
|
||||||
ukr.traineddata \
|
|
||||||
vie.traineddata
|
|
||||||
|
|
||||||
SUBDIRS = configs tessconfigs
|
SUBDIRS = configs tessconfigs
|
||||||
|
|
||||||
|
@ -2028,7 +2028,7 @@ void TableFinder::WriteToPix(const FCOORD& reskew) {
|
|||||||
|
|
||||||
BOXA* table_array = boxaCreate(num_boxes);
|
BOXA* table_array = boxaCreate(num_boxes);
|
||||||
// text file containing detected table bounding boxes
|
// text file containing detected table bounding boxes
|
||||||
FILE* fptr = fopen("tess-table.txt", "w");
|
FILE* fptr = fopen("tess-table.txt", "wb");
|
||||||
GridSearch<ColSegment, ColSegment_CLIST, ColSegment_C_IT>
|
GridSearch<ColSegment, ColSegment_CLIST, ColSegment_C_IT>
|
||||||
table_search(&table_grid_);
|
table_search(&table_grid_);
|
||||||
table_search.StartFullSearch();
|
table_search.StartFullSearch();
|
||||||
|
@ -155,7 +155,7 @@ int main (
|
|||||||
int num_fonts = 0;
|
int num_fonts = 0;
|
||||||
while ((PageName = GetNextFilename(argc, argv)) != NULL) {
|
while ((PageName = GetNextFilename(argc, argv)) != NULL) {
|
||||||
printf("Reading %s ...\n", PageName);
|
printf("Reading %s ...\n", PageName);
|
||||||
TrainingPage = Efopen(PageName, "r");
|
TrainingPage = Efopen(PageName, "rb");
|
||||||
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE,
|
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE,
|
||||||
100, 1.0f / 64.0f, 0.0f, NULL, TrainingPage, &CharList);
|
100, 1.0f / 64.0f, 0.0f, NULL, TrainingPage, &CharList);
|
||||||
fclose(TrainingPage);
|
fclose(TrainingPage);
|
||||||
@ -238,7 +238,7 @@ void WriteNormProtos (
|
|||||||
}
|
}
|
||||||
strcat (Filename, "normproto");
|
strcat (Filename, "normproto");
|
||||||
printf ("\nWriting %s ...", Filename);
|
printf ("\nWriting %s ...", Filename);
|
||||||
File = Efopen (Filename, "w");
|
File = Efopen (Filename, "wb");
|
||||||
fprintf(File,"%0d\n",Clusterer->SampleSize);
|
fprintf(File,"%0d\n",Clusterer->SampleSize);
|
||||||
WriteParamDesc(File,Clusterer->SampleSize,Clusterer->ParamDesc);
|
WriteParamDesc(File,Clusterer->SampleSize,Clusterer->ParamDesc);
|
||||||
iterate(LabeledProtoList)
|
iterate(LabeledProtoList)
|
||||||
|
@ -370,10 +370,10 @@ void WriteTrainingSamples (
|
|||||||
|
|
||||||
/* if file does not exist, create a new one with an appropriate
|
/* if file does not exist, create a new one with an appropriate
|
||||||
header; otherwise append samples to the existing file */
|
header; otherwise append samples to the existing file */
|
||||||
File = fopen (Filename, "r");
|
File = fopen (Filename, "rb");
|
||||||
if (File == NULL)
|
if (File == NULL)
|
||||||
{
|
{
|
||||||
File = Efopen (Filename, "w");
|
File = Efopen (Filename, "wb");
|
||||||
WriteOldParamDesc(
|
WriteOldParamDesc(
|
||||||
File,
|
File,
|
||||||
FeatureDefs.FeatureDesc[ShortNameToFeatureType(
|
FeatureDefs.FeatureDesc[ShortNameToFeatureType(
|
||||||
@ -382,7 +382,7 @@ void WriteTrainingSamples (
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose (File);
|
fclose (File);
|
||||||
File = Efopen (Filename, "a");
|
File = Efopen (Filename, "ab");
|
||||||
}
|
}
|
||||||
|
|
||||||
// append samples onto the file
|
// append samples onto the file
|
||||||
|
@ -225,7 +225,7 @@ int main (int argc, char **argv) {
|
|||||||
|
|
||||||
// Populate fontinfo_table with font properties.
|
// Populate fontinfo_table with font properties.
|
||||||
if (InputFontInfoFile != NULL) {
|
if (InputFontInfoFile != NULL) {
|
||||||
FILE* f = fopen(InputFontInfoFile, "r");
|
FILE* f = fopen(InputFontInfoFile, "rb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
fprintf(stderr, "Failed to load font_properties\n");
|
fprintf(stderr, "Failed to load font_properties\n");
|
||||||
} else {
|
} else {
|
||||||
@ -292,7 +292,7 @@ int main (int argc, char **argv) {
|
|||||||
delete[] short_name;
|
delete[] short_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrainingPage = Efopen (PageName, "r");
|
TrainingPage = Efopen (PageName, "rb");
|
||||||
LIST char_list = NIL_LIST;
|
LIST char_list = NIL_LIST;
|
||||||
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE,
|
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE,
|
||||||
0, 1.0f / 128.0f, 1.0f / 64.0f, &unicharset_training,
|
0, 1.0f / 128.0f, 1.0f / 64.0f, &unicharset_training,
|
||||||
@ -371,11 +371,7 @@ int main (int argc, char **argv) {
|
|||||||
strcat (Filename, "/");
|
strcat (Filename, "/");
|
||||||
}
|
}
|
||||||
strcat (Filename, "inttemp");
|
strcat (Filename, "inttemp");
|
||||||
#ifdef __UNIX__
|
|
||||||
OutFile = Efopen (Filename, "w");
|
|
||||||
#else
|
|
||||||
OutFile = Efopen (Filename, "wb");
|
OutFile = Efopen (Filename, "wb");
|
||||||
#endif
|
|
||||||
classify->WriteIntTemplates(OutFile, IntTemplates, unicharset_training);
|
classify->WriteIntTemplates(OutFile, IntTemplates, unicharset_training);
|
||||||
fclose (OutFile);
|
fclose (OutFile);
|
||||||
strcpy (Filename, "");
|
strcpy (Filename, "");
|
||||||
@ -425,7 +421,7 @@ void WriteMicrofeat(
|
|||||||
strcat (Filename, "/");
|
strcat (Filename, "/");
|
||||||
}
|
}
|
||||||
strcat (Filename, "Microfeat");
|
strcat (Filename, "Microfeat");
|
||||||
File = Efopen (Filename, "w");
|
File = Efopen (Filename, "wb");
|
||||||
printf ("\nWriting Merged %s ...", Filename);
|
printf ("\nWriting Merged %s ...", Filename);
|
||||||
iterate(ClassList)
|
iterate(ClassList)
|
||||||
{
|
{
|
||||||
@ -516,7 +512,7 @@ void InitXHeights(const char *filename,
|
|||||||
int xheights[]) {
|
int xheights[]) {
|
||||||
for (int i = 0; i < fontinfo_table.size(); ++i) xheights[i] = -1;
|
for (int i = 0; i < fontinfo_table.size(); ++i) xheights[i] = -1;
|
||||||
if (filename == NULL) return;
|
if (filename == NULL) return;
|
||||||
FILE *f = fopen(filename, "r");
|
FILE *f = fopen(filename, "rb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
fprintf(stderr, "Failed to load font xheights from %s\n", filename);
|
fprintf(stderr, "Failed to load font xheights from %s\n", filename);
|
||||||
return;
|
return;
|
||||||
@ -542,7 +538,7 @@ void AddSpacingInfo(const char *filename,
|
|||||||
const UNICHARSET &unicharset,
|
const UNICHARSET &unicharset,
|
||||||
const int xheights[],
|
const int xheights[],
|
||||||
UnicityTable<FontInfo> *fontinfo_table) {
|
UnicityTable<FontInfo> *fontinfo_table) {
|
||||||
FILE* fontinfo_file = fopen(filename, "r");
|
FILE* fontinfo_file = fopen(filename, "rb");
|
||||||
if (fontinfo_file == NULL) return;
|
if (fontinfo_file == NULL) return;
|
||||||
tprintf("Reading spacing from %s ...\n", filename);
|
tprintf("Reading spacing from %s ...\n", filename);
|
||||||
int scale = kBlnXHeight / xheights[fontinfo_id];
|
int scale = kBlnXHeight / xheights[fontinfo_id];
|
||||||
|
@ -134,7 +134,7 @@ int main(int argc, char** argv) {
|
|||||||
for (; tessoptind < argc; ++tessoptind) {
|
for (; tessoptind < argc; ++tessoptind) {
|
||||||
printf("Extracting unicharset from %s\n", argv[tessoptind]);
|
printf("Extracting unicharset from %s\n", argv[tessoptind]);
|
||||||
|
|
||||||
FILE* box_file = fopen(argv[tessoptind], "r");
|
FILE* box_file = fopen(argv[tessoptind], "rb");
|
||||||
if (box_file == NULL) {
|
if (box_file == NULL) {
|
||||||
printf("Cannot open box file %s\n", argv[tessoptind]);
|
printf("Cannot open box file %s\n", argv[tessoptind]);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -91,7 +91,7 @@ int main(int argc, char** argv) {
|
|||||||
} else if (argc == 7) {
|
} else if (argc == 7) {
|
||||||
// Place words of different lengths in separate Dawgs.
|
// Place words of different lengths in separate Dawgs.
|
||||||
char str[CHARS_PER_LINE];
|
char str[CHARS_PER_LINE];
|
||||||
FILE *word_file = fopen(wordlist_filename, "r");
|
FILE *word_file = fopen(wordlist_filename, "rb");
|
||||||
if (word_file == NULL) {
|
if (word_file == NULL) {
|
||||||
tprintf("Failed to open wordlist file %s\n", wordlist_filename);
|
tprintf("Failed to open wordlist file %s\n", wordlist_filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -95,5 +95,5 @@ void create_fxdebug_win() { //make gradients win
|
|||||||
// DEBUG_XPOS,DEBUG_YPOS,
|
// DEBUG_XPOS,DEBUG_YPOS,
|
||||||
// DEBUG_XSIZE,DEBUG_YSIZE);
|
// DEBUG_XSIZE,DEBUG_YSIZE);
|
||||||
// else
|
// else
|
||||||
// fx_debug=fopen(fx_debugfile.string(),"w");
|
// fx_debug=fopen(fx_debugfile.string(),"wb");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user