Skip to content

Conversation

@n-poulsen
Copy link
Contributor

When running video analysis with cropping, the predicted poses are stored in the cropped image space. To get the coordinates of the pose in the space of the full video, the data stored in the _metadata.pickle can be used.

The extract_outlier_frames and create_video_with_all_detections did not take these offsets into account, meaning the video with all detections had its keypoints shifted, as did the machine labels.

This PR fixes both of these issues.

As create_video_with_all_detections has a croppingargument, the behavior is set such that:

  1. If cropping is given as an argument, that value is used (overriding the value stored in the metadata)
  2. If cropping is not given then metadata["data"]["cropping"] and metadata["data"]["cropping_parameters"] are used

@n-poulsen n-poulsen requested a review from MMathisLab March 13, 2024 16:25
@n-poulsen n-poulsen self-assigned this Mar 13, 2024
Copy link
Member

@MMathisLab MMathisLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@MMathisLab MMathisLab merged commit 96b71fc into main Mar 19, 2024
@MMathisLab MMathisLab deleted the niels/video_cropping_bugs branch June 5, 2024 09:25
deruyter92 added a commit to deruyter92/DeepLabCut that referenced this pull request Jan 8, 2026
…re cropped in `extract_outlier_frames`.

This commit fixes a bug that introduces a mismatch between label-coordinates and video, when extracting cropped outlier frames.

When the `analyze_videos` step was performed using a cropping window. The predicted keypoints are stored in the crop-window space. In the previous implementation, the keypoints are ALWAYS converted back to reflect full-video coordinates by adding the left and top crop margins (introduced in PR DeepLabCut#2538). However the keypoints should only be converted back if the output frames are full-video, not when they are cropped. This commit fixes that by using the difference between the output margin and the margin stored in metadata.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants