Ensure bounding box is within camera frame (#3702)

* Ensure bounding box is within camera frame

* Account for 0 index
This commit is contained in:
Nicolas Mowen 2022-08-24 06:39:47 -06:00 committed by GitHub
parent 0cf759acad
commit 911d6fdfa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -647,12 +647,13 @@ def process_frames(
# apply non-maxima suppression to suppress weak, overlapping bounding boxes # apply non-maxima suppression to suppress weak, overlapping bounding boxes
# o[2] is the box of the object: xmin, ymin, xmax, ymax # o[2] is the box of the object: xmin, ymin, xmax, ymax
# apply max/min to ensure values do not exceed the known frame size
boxes = [ boxes = [
( (
o[2][0], max(o[2][0], 0),
o[2][1], max(o[2][1], 0),
o[2][2] - o[2][0], min(o[2][2] - o[2][0], detect_config.width - 1),
o[2][3] - o[2][1], min(o[2][3] - o[2][1], detect_config.height - 1),
) )
for o in group for o in group
] ]