mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
Avoid FP overflow in NormEvidenceOf (fixes issue #4257)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
b0a10bbe1a
commit
dac6b18a47
@ -105,13 +105,17 @@ float Classify::ComputeNormMatch(CLASS_ID ClassId, const FEATURE_STRUCT &feature
|
||||
return (1 - NormEvidenceOf(Match));
|
||||
}
|
||||
|
||||
float BestMatch = FLT_MAX;
|
||||
LIST Protos = NormProtos->Protos[ClassId];
|
||||
|
||||
if (DebugMatch) {
|
||||
tprintf("\nChar norm for class %s\n", unicharset.id_to_unichar(ClassId));
|
||||
}
|
||||
|
||||
LIST Protos = NormProtos->Protos[ClassId];
|
||||
if (Protos == nullptr) {
|
||||
// Avoid FP overflow in NormEvidenceOf.
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
float BestMatch = FLT_MAX;
|
||||
iterate(Protos) {
|
||||
auto Proto = reinterpret_cast<PROTOTYPE *>(Protos->first_node());
|
||||
float Delta = feature.Params[CharNormY] - Proto->Mean[CharNormY];
|
||||
|
Loading…
Reference in New Issue
Block a user