-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FP division by zero (issue #3995) #3996
Conversation
src/wordrec/language_model.cpp
Outdated
@@ -1375,7 +1375,12 @@ void LanguageModel::ExtractFeaturesFromPath(const ViterbiStateEntry &vse, float | |||
// features[PTRAIN_NUM_BAD_FONT] = vse.consistency_info.inconsistent_font; | |||
|
|||
// Classifier-related features. | |||
features[PTRAIN_RATING_PER_CHAR] = vse.ratings_sum / static_cast<float>(vse.outline_length); | |||
if (vse.outline_length != 0.0f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
features[PTRAIN_RATING_PER_CHAR] = (vse.outline_length > 0.0f) ? (vse.ratings_sum / static_cast<float>(vse.outline_length)) : 0.0f;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would that be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @stweil .
(vse.outline_length != 0.0f)
!!! (float
?)
If not (float)
then replace with (vse.outline_length != 0)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I replaced !=
by >
now. Please review the updated code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @stweil .
vse.outline_length
is it (float)
? See #3996 (comment)
PS:
tesseract/src/wordrec/lm_state.h
Line 190 in 4142b32
float outline_length; ///< length of the outline so far |
Resolved. 👍
Signed-off-by: Stefan Weil <sw@weilnetz.de>
…sue tesseract-ocr#3995) Signed-off-by: Stefan Weil <sw@weilnetz.de>
No description provided.