Skip to content

Commit

Permalink
Fixed counting of tracks when calculating analytics report (#8088)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed Jun 26, 2024
1 parent e8002b2 commit 1e331ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog.d/20240626_100703_boris_fixed_analytics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Incorrect counting of tracked shapes when computing analytics report
(<https://github.com/cvat-ai/cvat/pull/8088>)
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,31 @@ def get_track_count():

count = 0
for track in db_tracks:
# Skip processing if no shapes are associated with the track
if not track["shapes"]:
continue

# Skip skeleton shapes as their points are already counted
if track["shapes"] and track["shapes"][0]["type"] == ShapeType.SKELETON:
# skeleton's points are already counted as objects
continue

# If only one shape exists, calculate the frames from the first frame to the stop frame of the segment
if len(track["shapes"]) == 1:
count += self._db_obj.segment.stop_frame - track["shapes"][0]["frame"] + 1
continue

# Add the initial frame count and then iterate through shapes to count non-outside frames
count += 1
for prev_shape, cur_shape in zip(track["shapes"], track["shapes"][1:]):
if not prev_shape["outside"]:
count += cur_shape["frame"] - prev_shape["frame"] + 1
count += cur_shape["frame"] - prev_shape["frame"]

# Add frames until the end of segment if the latest shape was not outside
if (
not cur_shape["outside"]
and cur_shape["frame"] < self._db_obj.segment.stop_frame
):
count += self._db_obj.segment.stop_frame - cur_shape["frame"]

return count

Expand Down

0 comments on commit 1e331ba

Please sign in to comment.