Video analysis on cropped videos: bug fixes for `extract_outlier_frames` and `create_video_with_all_detections` by n-poulsen · Pull Request #2538 · DeepLabCut/DeepLabCut

added 2 commits

March 13, 2024 17:16

MMathisLab

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.

MMathisLab added a commit that referenced this pull request

Jan 22, 2026
* Fix unintended keypoint conversion to full-frame when output frames are 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 #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.

* Update deeplabcut/refine_training_dataset/outlier_frames.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update deeplabcut/refine_training_dataset/outlier_frames.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update deeplabcut/refine_training_dataset/outlier_frames.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Mackenzie Mathis <mathis@rowland.harvard.edu>