talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
435 stars 97 forks source link

GUI: Image is not updated when switching videos #1530

Closed roomrys closed 5 months ago

roomrys commented 1 year ago

Bug description

⚠️ Only present on the multiview branch. Only present if on last frame of video when switching videos.

Argh! It was a video encoding problem with the MV test videos.

The callback for the "video" state loads the new video image at this line (but this does not happen when switching videos on the last frame prior to updating the "video" state). https://github.com/talmolab/sleap/blob/0134ab443663bf1b1f0287d632dce9fdef80c14b/sleap/gui/widgets/video.py#L172

This is a regression. In the past, the image would update when selecting a new video in the GUI.

Currently, users need to change frames after selecting a video to update the plotted image. This is also noticeable in start-up of the GUI where the default background image remains present even if a video is loaded.

image

Initial frame loaded correctly, but then when switching to a new video, the plot is not updated:

image

Expected behaviour

After selecting a video, the plotted image should automatically update.

Actual behaviour

The image only updates when selecting a new frame in the seekbar/arrow keys.

Your personal set up

roomrys commented 1 year ago

Trace

On initialization, the QtVideoPlayer connects the "video" state to a callback https://github.com/talmolab/sleap/blob/6b14bcab93b8c1953913dcfbabd6508f78f77e8a/sleap/gui/widgets/video.py#L278

more specifically, the QtVideoPlayer.load_video function https://github.com/talmolab/sleap/blob/6b14bcab93b8c1953913dcfbabd6508f78f77e8a/sleap/gui/widgets/video.py#L398

which calls QtVideoPlayer.plot https://github.com/talmolab/sleap/blob/6b14bcab93b8c1953913dcfbabd6508f78f77e8a/sleap/gui/widgets/video.py#L480

which uses an image loader to set the image once loaded https://github.com/talmolab/sleap/blob/6b14bcab93b8c1953913dcfbabd6508f78f77e8a/sleap/gui/widgets/video.py#L260-L263

Is the video state being updated when we switch video's? After a video that is missing is found?

The VideosDock.table attribute has has a function activateSelected which will change the state["video"] if table.is_activatable https://github.com/talmolab/sleap/blob/1e0627aae2e69e664d8eca0dd3af04ba8dd9b13c/sleap/gui/dataviews.py#L340-L347

(and assuming table.row_name == "video" - which is true) https://github.com/talmolab/sleap/blob/1e0627aae2e69e664d8eca0dd3af04ba8dd9b13c/sleap/gui/widgets/docks.py#L179

we call activateSelected when a row item is double clicked https://github.com/talmolab/sleap/blob/1e0627aae2e69e664d8eca0dd3af04ba8dd9b13c/sleap/gui/dataviews.py#L328

roomrys commented 5 months ago

Fixed with #1787