From 1e331baff99fb476afb910c1499762d7f2b0aef8 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 26 Jun 2024 11:28:59 +0300 Subject: [PATCH] Fixed counting of tracks when calculating analytics report (#8088) --- .../20240626_100703_boris_fixed_analytics.md | 4 ++++ .../primary_metrics/annotation_speed.py | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20240626_100703_boris_fixed_analytics.md diff --git a/changelog.d/20240626_100703_boris_fixed_analytics.md b/changelog.d/20240626_100703_boris_fixed_analytics.md new file mode 100644 index 000000000000..d4241c830ec1 --- /dev/null +++ b/changelog.d/20240626_100703_boris_fixed_analytics.md @@ -0,0 +1,4 @@ +### Fixed + +- Incorrect counting of tracked shapes when computing analytics report + () diff --git a/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py b/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py index 03ec983297e6..779f3cfccc14 100644 --- a/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py +++ b/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py @@ -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