Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed counting of tracks when calculating analytics report #8088

Merged
merged 6 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading