Fix edge of frame after region adjustments

This commit is contained in:
Nick Mowen 2022-09-12 10:54:50 -06:00 committed by Blake Blackshear
parent 7e9f913ff6
commit 1bc8d94312

View File

@ -440,7 +440,13 @@ def intersects_any(box_a, boxes):
def detect(
object_detector, frame, model_shape, region, objects_to_track, object_filters
detect_config: DetectConfig,
object_detector,
frame,
model_shape,
region,
objects_to_track,
object_filters,
):
tensor_input = create_tensor_input(frame, model_shape, region)
@ -449,10 +455,10 @@ def detect(
for d in region_detections:
box = d[2]
size = region[2] - region[0]
x_min = int((box[1] * size) + region[0])
y_min = int((box[0] * size) + region[1])
x_max = int((box[3] * size) + region[0])
y_max = int((box[2] * size) + region[1])
x_min = int(max(0, (box[1] * size) + region[0]))
y_min = int(max(0, (box[0] * size) + region[1]))
x_max = int(min(detect_config.width, (box[3] * size) + region[0]))
y_max = int(min(detect_config.height, (box[2] * size) + region[1]))
width = x_max - x_min
height = y_max - y_min
area = width * height
@ -620,6 +626,7 @@ def process_frames(
for region in regions:
detections.extend(
detect(
detect_config,
object_detector,
frame,
model_shape,
@ -679,6 +686,7 @@ def process_frames(
selected_objects.extend(
detect(
detect_config,
object_detector,
frame,
model_shape,