mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-19 06:53:36 +08:00
Replace Efopen by fopen and remove efio.cpp, efio.h
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
909af5d978
commit
b57afc7c78
@ -36,7 +36,6 @@
|
||||
#include "stopper.h"
|
||||
#include "intmatcher.h"
|
||||
#include "chop.h"
|
||||
#include "efio.h"
|
||||
#include "danerror.h"
|
||||
#include "globals.h"
|
||||
#ifndef ANDROID_BUILD
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "classify.h"
|
||||
#include "efio.h"
|
||||
#include "featdefs.h"
|
||||
#include "mf.h"
|
||||
#include "normfeat.h"
|
||||
@ -95,12 +94,15 @@ void Classify::LearnBlob(const STRING& fontname, TBLOB* blob,
|
||||
// Writes stored training data to a .tr file based on the given filename.
|
||||
// Returns false on error.
|
||||
bool Classify::WriteTRFile(const STRING& filename) {
|
||||
bool result = false;
|
||||
STRING tr_filename = filename + ".tr";
|
||||
FILE* fp = Efopen(tr_filename.string(), "wb");
|
||||
const size_t len = tr_file_data_.length();
|
||||
const bool result =
|
||||
fwrite(&tr_file_data_[0], sizeof(tr_file_data_[0]), len, fp) == len;
|
||||
fclose(fp);
|
||||
FILE* fp = fopen(tr_filename.string(), "wb");
|
||||
if (fp) {
|
||||
const size_t len = tr_file_data_.length();
|
||||
result =
|
||||
fwrite(&tr_file_data_[0], sizeof(tr_file_data_[0]), len, fp) == len;
|
||||
fclose(fp);
|
||||
}
|
||||
tr_file_data_.truncate_at(0);
|
||||
return result;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "classify.h"
|
||||
#include "efio.h"
|
||||
#include "globals.h"
|
||||
#include "helpers.h"
|
||||
#include "serialis.h"
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "allheaders.h"
|
||||
#include "boxread.h"
|
||||
#include "classify.h"
|
||||
#include "efio.h"
|
||||
#include "errorcounter.h"
|
||||
#include "featdefs.h"
|
||||
#include "sampleiterator.h"
|
||||
@ -121,7 +120,7 @@ void MasterTrainer::ReadTrainingSamples(const char* page_name,
|
||||
const int cn_feature_type = ShortNameToFeatureType(feature_defs, kCNFeatureType);
|
||||
const int geo_feature_type = ShortNameToFeatureType(feature_defs, kGeoFeatureType);
|
||||
|
||||
FILE* fp = Efopen(page_name, "rb");
|
||||
FILE* fp = fopen(page_name, "rb");
|
||||
if (fp == nullptr) {
|
||||
tprintf("Failed to open tr file: %s\n", page_name);
|
||||
return;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "classify.h"
|
||||
#include "clusttool.h"
|
||||
#include "const.h"
|
||||
#include "efio.h"
|
||||
#include "emalloc.h"
|
||||
#include "globals.h"
|
||||
#include "helpers.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "outfeat.h"
|
||||
|
||||
#include "classify.h"
|
||||
#include "efio.h"
|
||||
#include "featdefs.h"
|
||||
#include "mfoutline.h"
|
||||
#include "ocrfeatures.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "picofeat.h"
|
||||
|
||||
#include "classify.h"
|
||||
#include "efio.h"
|
||||
#include "featdefs.h"
|
||||
#include "fpoint.h"
|
||||
#include "mfoutline.h"
|
||||
|
@ -8,13 +8,13 @@ AM_CPPFLAGS += -DTESS_EXPORTS \
|
||||
endif
|
||||
|
||||
noinst_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 \
|
||||
emalloc.h globals.h \
|
||||
oldlist.h structures.h
|
||||
|
||||
noinst_LTLIBRARIES = libtesseract_cutil.la
|
||||
|
||||
libtesseract_cutil_la_SOURCES = \
|
||||
bitvec.cpp callcpp.cpp cutil.cpp cutil_class.cpp danerror.cpp efio.cpp \
|
||||
bitvec.cpp callcpp.cpp cutil.cpp cutil_class.cpp danerror.cpp \
|
||||
emalloc.cpp \
|
||||
oldlist.cpp structures.cpp
|
||||
|
@ -1,55 +0,0 @@
|
||||
/******************************************************************************
|
||||
** Filename: efio.c
|
||||
** Purpose: Utility I/O routines
|
||||
** Author: Dan Johnson
|
||||
** History: 5/21/89, DSJ, Created.
|
||||
**
|
||||
** (c) Copyright Hewlett-Packard Company, 1988.
|
||||
** 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 Files and Type Defines
|
||||
----------------------------------------------------------------------------*/
|
||||
#include "efio.h"
|
||||
#include "danerror.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#define MAXERRORMESSAGE 256
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Public Code
|
||||
----------------------------------------------------------------------------*/
|
||||
/**
|
||||
* This routine attempts to open the specified file in the
|
||||
* specified mode. If the file can be opened, a pointer to
|
||||
* the open file is returned. If the file cannot be opened,
|
||||
* an error is trapped.
|
||||
* @param Name name of file to be opened
|
||||
* @param Mode mode to be used to open file
|
||||
* @return Pointer to open file.
|
||||
* @note Globals: None
|
||||
* @note Exceptions: #FOPENERROR unable to open specified file
|
||||
* @note History: 5/21/89, DSJ, Created.
|
||||
*/
|
||||
FILE *Efopen(const char *Name, const char *Mode) {
|
||||
FILE *File;
|
||||
char ErrorMessage[MAXERRORMESSAGE];
|
||||
|
||||
File = fopen (Name, Mode);
|
||||
if (File == nullptr) {
|
||||
sprintf (ErrorMessage, "Unable to open %s", Name);
|
||||
DoError(FOPENERROR, ErrorMessage);
|
||||
return (nullptr);
|
||||
}
|
||||
else
|
||||
return (File);
|
||||
} /* Efopen */
|
@ -1,32 +0,0 @@
|
||||
/******************************************************************************
|
||||
** Filename: efio.h
|
||||
** Purpose: Definition of file I/O routines
|
||||
** Author: Dan Johnson
|
||||
** History: 5/21/89, DSJ, Created.
|
||||
**
|
||||
** (c) Copyright Hewlett-Packard Company, 1988.
|
||||
** 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.
|
||||
******************************************************************************/
|
||||
#ifndef EFIO_H
|
||||
#define EFIO_H
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
Include Files and Type Defines
|
||||
----------------------------------------------------------------------------**/
|
||||
#include <cstdio>
|
||||
|
||||
#define FOPENERROR 3000
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
Public Function Prototype
|
||||
----------------------------------------------------------------------------**/
|
||||
FILE *Efopen(const char *Name, const char *Mode);
|
||||
#endif
|
@ -27,7 +27,6 @@
|
||||
#include "const.h"
|
||||
#include "danerror.h"
|
||||
#include "dict.h"
|
||||
#include "efio.h"
|
||||
#include "helpers.h"
|
||||
#include "matchdefs.h"
|
||||
#include "pageres.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
Include Files and Type Defines
|
||||
----------------------------------------------------------------------------*/
|
||||
#include "oldlist.h"
|
||||
#include "efio.h"
|
||||
#include "emalloc.h"
|
||||
#include "featdefs.h"
|
||||
#include "tessopt.h"
|
||||
@ -120,7 +119,6 @@ int main(int argc, char *argv[]) {
|
||||
Config = CNConfig;
|
||||
|
||||
const char *PageName;
|
||||
FILE *TrainingPage;
|
||||
LIST CharList = NIL_LIST;
|
||||
CLUSTERER *Clusterer = nullptr;
|
||||
LIST ProtoList = NIL_LIST;
|
||||
@ -134,11 +132,14 @@ int main(int argc, char *argv[]) {
|
||||
int num_fonts = 0;
|
||||
while ((PageName = GetNextFilename(argc, argv)) != nullptr) {
|
||||
printf("Reading %s ...\n", PageName);
|
||||
TrainingPage = Efopen(PageName, "rb");
|
||||
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE, 100, nullptr,
|
||||
TrainingPage, &CharList);
|
||||
fclose(TrainingPage);
|
||||
++num_fonts;
|
||||
FILE *TrainingPage = fopen(PageName, "rb");
|
||||
ASSERT_HOST(TrainingPage);
|
||||
if (TrainingPage) {
|
||||
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE, 100, nullptr,
|
||||
TrainingPage, &CharList);
|
||||
fclose(TrainingPage);
|
||||
++num_fonts;
|
||||
}
|
||||
}
|
||||
printf("Clustering ...\n");
|
||||
// To allow an individual font to form a separate cluster,
|
||||
@ -220,7 +221,8 @@ static void WriteNormProtos(const char *Directory, LIST LabeledProtoList,
|
||||
}
|
||||
Filename += "normproto";
|
||||
printf ("\nWriting %s ...", Filename.string());
|
||||
File = Efopen (Filename.string(), "wb");
|
||||
File = fopen(Filename.string(), "wb");
|
||||
ASSERT_HOST(File);
|
||||
fprintf(File, "%0d\n", feature_desc->NumParams);
|
||||
WriteParamDesc(File, feature_desc->NumParams, feature_desc->ParamDesc);
|
||||
iterate(LabeledProtoList)
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "classify.h"
|
||||
#include "cluster.h"
|
||||
#include "clusttool.h"
|
||||
#include "efio.h"
|
||||
#include "emalloc.h"
|
||||
#include "featdefs.h"
|
||||
#include "fontinfo.h"
|
||||
|
@ -17,7 +17,6 @@
|
||||
******************************************************************************/
|
||||
#include "mergenf.h"
|
||||
#include "host.h"
|
||||
#include "efio.h"
|
||||
#include "clusttool.h"
|
||||
#include "cluster.h"
|
||||
#include "oldlist.h"
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "clusttool.h"
|
||||
#include "commontraining.h"
|
||||
#include "danerror.h"
|
||||
#include "efio.h"
|
||||
#include "emalloc.h"
|
||||
#include "featdefs.h"
|
||||
#include "fontinfo.h"
|
||||
|
Loading…
Reference in New Issue
Block a user