Skip to content

Commit

Permalink
Replace FLOAT32 by float data type
Browse files Browse the repository at this point in the history
On most systems float is the IEEE 754 single-precision binary
floating-point format (32 bits). Tesseract does not support other systems.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 2, 2018
1 parent f6c3c8c commit faae87b
Show file tree
Hide file tree
Showing 39 changed files with 625 additions and 682 deletions.
1 change: 0 additions & 1 deletion src/ccutil/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <cstdint> // int32_t, ...

// definitions of portable data types (numbers and characters)
using FLOAT32 = float;
using BOOL8 = unsigned char;

#if defined(_WIN32)
Expand Down
24 changes: 12 additions & 12 deletions src/classify/adaptmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "fontinfo.h" // for ScoredFont, FontSet
#include "genericvector.h" // for GenericVector
#include "helpers.h" // for IntCastRounded, ClipToRange
#include "host.h" // for FLOAT32, FALSE, TRUE
#include "host.h" // for FALSE, TRUE
#include "intfx.h" // for BlobToTrainingSample, INT_FX_RESULT_S...
#include "intmatcher.h" // for CP_RESULT_STRUCT, IntegerMatcher
#include "intproto.h" // for INT_FEATURE_STRUCT, (anonymous), Clas...
Expand Down Expand Up @@ -95,7 +95,7 @@ struct ADAPT_RESULTS {
bool HasNonfragment;
UNICHAR_ID best_unichar_id;
int best_match_index;
FLOAT32 best_rating;
float best_rating;
GenericVector<UnicharRating> match;
GenericVector<CP_RESULT_STRUCT> CPResults;

Expand Down Expand Up @@ -155,11 +155,11 @@ static float ScoredUnichar(UNICHAR_ID id, const ADAPT_RESULTS& results) {
return results.match[index].rating;
}

void InitMatcherRatings(FLOAT32 *Rating);
void InitMatcherRatings(float *Rating);

int MakeTempProtoPerm(void *item1, void *item2);

void SetAdaptiveThreshold(FLOAT32 Threshold);
void SetAdaptiveThreshold(float Threshold);


/*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -879,7 +879,7 @@ bool Classify::AdaptableWord(WERD_RES* word) {
* @note History: Thu Mar 14 09:36:03 1991, DSJ, Created.
*/
void Classify::AdaptToChar(TBLOB* Blob, CLASS_ID ClassId, int FontinfoId,
FLOAT32 Threshold,
float Threshold,
ADAPT_TEMPLATES adaptive_templates) {
int NumFeatures;
INT_FEATURE_ARRAY IntFeatures;
Expand Down Expand Up @@ -1456,8 +1456,8 @@ void Classify::ConvertMatchesToChoices(const DENORM& denorm, const TBOX& box,
ADAPT_RESULTS *Results,
BLOB_CHOICE_LIST *Choices) {
assert(Choices != nullptr);
FLOAT32 Rating;
FLOAT32 Certainty;
float Rating;
float Certainty;
BLOB_CHOICE_IT temp_it;
bool contains_nonfrag = false;
temp_it.set_to_list(Choices);
Expand Down Expand Up @@ -1893,9 +1893,9 @@ PROTO_ID Classify::MakeNewTempProtos(FEATURE_SET Features,
TEMP_PROTO TempProto;
PROTO Proto;
FEATURE F1, F2;
FLOAT32 X1, X2, Y1, Y2;
FLOAT32 A1, A2, AngleDelta;
FLOAT32 SegmentLength;
float X1, X2, Y1, Y2;
float A1, A2, AngleDelta;
float SegmentLength;
PROTO_ID Pid;

for (ProtoStart = BadFeat, LastBad = ProtoStart + NumBadFeat;
Expand Down Expand Up @@ -2093,7 +2093,7 @@ void Classify::PrintAdaptiveMatchResults(const ADAPT_RESULTS& results) {
*/
void Classify::RemoveBadMatches(ADAPT_RESULTS *Results) {
int Next, NextGood;
FLOAT32 BadMatchThreshold;
float BadMatchThreshold;
static const char* romans = "i v x I V X";
BadMatchThreshold = Results->best_rating - matcher_bad_match_pad;

Expand Down Expand Up @@ -2204,7 +2204,7 @@ void Classify::RemoveExtraPuncs(ADAPT_RESULTS *Results) {
* @note Exceptions: none
* @note History: Tue Apr 9 08:33:13 1991, DSJ, Created.
*/
void Classify::SetAdaptiveThreshold(FLOAT32 Threshold) {
void Classify::SetAdaptiveThreshold(float Threshold) {
Threshold = (Threshold == matcher_good_threshold) ? 0.9: (1.0 - Threshold);
classify_adapt_proto_threshold.set_value(
ClipToRange<int>(255 * Threshold, 0, 255));
Expand Down
10 changes: 5 additions & 5 deletions src/classify/classify.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class Classify : public CCStruct {
void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates);
ADAPT_TEMPLATES ReadAdaptedTemplates(TFile* File);
/* normmatch.cpp ************************************************************/
FLOAT32 ComputeNormMatch(CLASS_ID ClassId,
const FEATURE_STRUCT& feature, bool DebugMatch);
float ComputeNormMatch(CLASS_ID ClassId,
const FEATURE_STRUCT& feature, bool DebugMatch);
void FreeNormProtos();
NORM_PROTOS* ReadNormProtos(TFile* fp);
/* protos.cpp ***************************************************************/
Expand Down Expand Up @@ -213,7 +213,7 @@ class Classify : public CCStruct {
void PrintAdaptiveMatchResults(const ADAPT_RESULTS& results);
void RemoveExtraPuncs(ADAPT_RESULTS *Results);
void RemoveBadMatches(ADAPT_RESULTS *Results);
void SetAdaptiveThreshold(FLOAT32 Threshold);
void SetAdaptiveThreshold(float Threshold);
void ShowBestMatchFor(int shape_id,
const INT_FEATURE_STRUCT* features,
int num_features);
Expand Down Expand Up @@ -252,7 +252,7 @@ class Classify : public CCStruct {
UNICHAR_ID *GetAmbiguities(TBLOB *Blob, CLASS_ID CorrectClass);
void DoAdaptiveMatch(TBLOB *Blob, ADAPT_RESULTS *Results);
void AdaptToChar(TBLOB* Blob, CLASS_ID ClassId, int FontinfoId,
FLOAT32 Threshold, ADAPT_TEMPLATES adaptive_templates);
float Threshold, ADAPT_TEMPLATES adaptive_templates);
void DisplayAdaptedChar(TBLOB* blob, INT_CLASS_STRUCT* int_class);
bool AdaptableWord(WERD_RES* word);
void EndAdaptiveClassifier();
Expand Down Expand Up @@ -350,7 +350,7 @@ class Classify : public CCStruct {
return fontset_table_;
}
/* mfoutline.cpp ***********************************************************/
void NormalizeOutlines(LIST Outlines, FLOAT32 *XScale, FLOAT32 *YScale);
void NormalizeOutlines(LIST Outlines, float *XScale, float *YScale);
/* outfeat.cpp ***********************************************************/
FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob);
/* picofeat.cpp ***********************************************************/
Expand Down
Loading

0 comments on commit faae87b

Please sign in to comment.