Skip to content

Commit

Permalink
Fix CID 1164553 (Division or modulo by float zero)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 1, 2018
1 parent 1b303e5 commit 09da044
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/ccmain/applybox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,10 @@ void Tesseract::MaximallyChopWord(const GenericVector<TBOX>& boxes,
/// miss metric gets the blob.
static double BoxMissMetric(const TBOX& box1, const TBOX& box2) {
const int overlap_area = box1.intersection(box2).area();
double miss_metric = box1.area()- overlap_area;
miss_metric /= box1.area();
miss_metric *= box2.area() - overlap_area;
miss_metric /= box2.area();
return miss_metric;
const int a = box1.area();
const int b = box2.area();
ASSERT_HOST(a != 0 && b != 0);
return 1.0 * (a - overlap_area) * (b - overlap_area) / a / b;
}

/// Gather consecutive blobs that match the given box into the best_state
Expand Down

0 comments on commit 09da044

Please sign in to comment.