[tracks, detections] add frame and all keypoint coordinates to Detection
This commit is contained in:
parent
a1353727c7
commit
6c75d24f97
@ -119,18 +119,21 @@ class DetectionView(QWidget):
|
||||
self._scene.removeItem(it)
|
||||
del it
|
||||
|
||||
def addDetections(self, coordinates:np.array, track_ids:np.array, detection_ids:np.array, brush:QBrush):
|
||||
def addDetections(self, coordinates:np.array, track_ids:np.array, detection_ids:np.array, frames: np.array,
|
||||
keypoint:int, brush:QBrush):
|
||||
image_rect = self._pixmapitem.boundingRect() if self._pixmapitem is not None else QRectF(0,0,0,0)
|
||||
num_detections = coordinates.shape[0]
|
||||
for i in range(num_detections):
|
||||
x = coordinates[i, 0]
|
||||
y = coordinates[i, 1]
|
||||
x = coordinates[i, keypoint, 0]
|
||||
y = coordinates[i, keypoint, 1]
|
||||
c = brush.color()
|
||||
c.setAlpha(int(i * 255 / num_detections))
|
||||
brush.setColor(c)
|
||||
item = Detection(image_rect.left() + x, image_rect.top() + y, 20, 20, brush=brush)
|
||||
item.setData(0, track_ids[i])
|
||||
item.setData(1, detection_ids[i])
|
||||
item.setData(2, coordinates[i, :, :])
|
||||
item.setData(3, frames[i])
|
||||
item = self._scene.addItem(item)
|
||||
logging.debug("DetectionView: Number of items in scene: %i", len(self._scene.items()))
|
||||
|
||||
|
@ -428,10 +428,11 @@ class FixTracks(QWidget):
|
||||
if len(df) == 0:
|
||||
return
|
||||
keypoint = self._keypointcombo.currentIndex()
|
||||
coords = np.stack(df["keypoints"].values).astype(np.float32)[:, keypoint,:]
|
||||
coords = np.stack(df["keypoints"].values).astype(np.float32)[:, :,:]
|
||||
tracks = df["track"].values.astype(int)
|
||||
ids = df.index.values.astype(int)
|
||||
self._detectionView.addDetections(coords, tracks, ids, self._brushes[name])
|
||||
frames = df["frame"].values.astype(int)
|
||||
self._detectionView.addDetections(coords, tracks, ids, frames, keypoint, self._brushes[name])
|
||||
|
||||
max_frames = self._data.max("frame")
|
||||
start = self._timeline.rangeStart
|
||||
@ -571,9 +572,11 @@ class FixTracks(QWidget):
|
||||
logging.debug("Tracks: Detections selected")
|
||||
tracks = np.zeros(len(detections))
|
||||
ids = np.zeros_like(tracks)
|
||||
coordinates = np.zeros((len(detections), ))
|
||||
for i, d in enumerate(detections):
|
||||
tracks[i] = d.data(0)
|
||||
ids[i] = d.data(1)
|
||||
|
||||
self._data.setUserSelection(ids)
|
||||
self._controls_widget.setSelectedTracks(tracks)
|
||||
self.update()
|
||||
|
Loading…
Reference in New Issue
Block a user