Fix logical errors

- field migrations require default values
- `clipped` referenced the wrong index for region, since it shifted
- missed an inclusion of `ratio` for detections in `process_frames`
- revert naming `o[2]` as `box` since it is out of scope!

This has now been test-run against a video, so I believe the kinks are
worked out.

Issue: #2948
This commit is contained in:
Nick 2022-03-12 09:35:44 -05:00
parent 3bb3aecf97
commit 2ad0ed9b8d
3 changed files with 10 additions and 7 deletions

View File

@ -522,7 +522,7 @@ def clipped(obj, frame_shape):
# if the object is within 5 pixels of the region border, and the region is not on the edge
# consider the object to be clipped
box = obj[2]
region = obj[4]
region = obj[5]
if (
(region[0] > 5 and box[0] - region[0] <= 5)
or (region[1] > 5 and box[1] - region[1] <= 5)

View File

@ -591,6 +591,7 @@ def process_frames(
obj["score"],
obj["box"],
obj["area"],
obj["ratio"],
obj["region"],
)
for obj in object_tracker.tracked_objects.values()
@ -626,13 +627,13 @@ def process_frames(
for group in detected_object_groups.values():
# apply non-maxima suppression to suppress weak, overlapping bounding boxes
box = o[2] # xmin, ymin, xmax, ymax
# o[2] is the box of the object: xmin, ymin, xmax, ymax
boxes = [
(
box[0],
box[1],
box[2] - box[0],
box[3] - box[1],
o[2][0],
o[2][1],
o[2][2] - o[2][0],
o[2][3] - o[2][1],
)
for o in group
]

View File

@ -30,7 +30,9 @@ SQL = pw.SQL
def migrate(migrator, database, fake=False, **kwargs):
migrator.add_fields(
Event,
ratio=pw.FloatField(),
ratio=pw.FloatField(
default=1.0
), # There is no way to get the true ratio from an existing recording, so simply assume they are square.
)