From 50d982c93b5dff743c046fffaf1b468ca36c8a64 Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan.grewe@g-node.org>
Date: Sat, 1 Mar 2025 16:50:27 +0100
Subject: [PATCH] [detectionview] fix bug, when no detection is in the current
 selection

---
 fixtracks/widgets/detectionview.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fixtracks/widgets/detectionview.py b/fixtracks/widgets/detectionview.py
index 4ee7e61..699c34f 100644
--- a/fixtracks/widgets/detectionview.py
+++ b/fixtracks/widgets/detectionview.py
@@ -142,9 +142,10 @@ class DetectionView(QWidget):
         scores = self._data.selectedData("confidence")
 
         image_rect = self._pixmapitem.boundingRect() if self._pixmapitem is not None else QRectF(0,0,0,0)
-
+        num_detections = len(frames)
         for i, (id, f, t, l, s) in enumerate(zip(ids, frames, tracks, userlabeled, scores)):
             c = Tracks.fromValue(t).toColor()
+            c.setAlpha(int(i * 255 / num_detections))
             if keypoint >= 0:
                 x = coordinates[i, keypoint, 0]
                 y = coordinates[i, keypoint, 1]