Skip to content

Commit

Permalink
Catching an error in RDE around zero-pixel bounding boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
agentmorris committed Nov 22, 2020
1 parent 70aaa5b commit bfe6af7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Expand Up @@ -297,10 +297,15 @@ def find_matches_in_directory(dirName, options, rowsByDirectory):

# Is this detection too big to be suspicious?
w, h = bbox[2], bbox[3]

if (w == 0 or h == 0):
# print('Illegal zero-size bounding box on image {}'.format(filename))
continue

area = h * w

# These are relative coordinates
assert area >= 0.0 and area <= 1.0
assert area >= 0.0 and area <= 1.0, 'Illegal bounding box area {}'.format(area)

if area > options.maxSuspiciousDetectionSize:
# print('Ignoring very large detection with area {}'.format(area))
Expand All @@ -321,6 +326,7 @@ def find_matches_in_directory(dirName, options, rowsByDirectory):
try:
iou = ct_utils.get_iou(bbox, candidate.bbox)
except Exception as e:
import pdb
print('Warning: IOU computation error on boxes ({},{},{},{}),({},{},{},{}): {}'.format(
bbox[0],bbox[1],bbox[2],bbox[3],
candidate.bbox[0],candidate.bbox[1],candidate.bbox[2],candidate.bbox[3], str(e)))
Expand Down
12 changes: 6 additions & 6 deletions ct_utils.py
Expand Up @@ -159,11 +159,11 @@ def get_iou(bb1, bb2):
bb1 = convert_xywh_to_xyxy(bb1)
bb2 = convert_xywh_to_xyxy(bb2)

assert bb1[0] < bb1[2]
assert bb1[1] < bb1[3]
assert bb1[0] < bb1[2], 'Malformed bounding box (x2 >= x1)'
assert bb1[1] < bb1[3], 'Malformed bounding box (y2 >= y1)'

assert bb2[0] < bb2[2]
assert bb2[1] < bb2[3]
assert bb2[0] < bb2[2], 'Malformed bounding box (x2 >= x1)'
assert bb2[1] < bb2[3], 'Malformed bounding box (y2 >= y1)'

# Determine the coordinates of the intersection rectangle
x_left = max(bb1[0], bb2[0])
Expand All @@ -186,6 +186,6 @@ def get_iou(bb1, bb2):
# area and dividing it by the sum of prediction + ground-truth
# areas - the intersection area.
iou = intersection_area / float(bb1_area + bb2_area - intersection_area)
assert iou >= 0.0
assert iou <= 1.0
assert iou >= 0.0, 'Illegal IOU < 0'
assert iou <= 1.0, 'Illegal IOU > 1'
return iou

0 comments on commit bfe6af7

Please sign in to comment.