Files
opencv-MIRROR/modules/video/test
Lazizbek Ergashev f2be0a0a28 Merge pull request #30358 from lazerg:fix/issue-30350-vittrack-clip-box
video: clip TrackerVit box to the image - #30358

Fixes #30350

`TrackerVitImpl::update()` never bounds the predicted box to the frame, and that box sets the size of the next search crop. Once it grows past the frame, the crop is mostly padding, the network keeps predicting a large box and it can grow until the crop allocation fails. The box is now clipped to the image after each update, the same way OSTrack does it (`clip_box(..., H, W, margin=10)`); NanoTrack and DaSiamRPN already clip their results too.

With the repro from the issue on the 4.14.0 normalization (before #30168), the box now stays at most the frame size instead of reaching ~5000 px and failing to allocate. On current 4.x the growth is slower, but the box still leaves the frame (for example 1106x882 on a 720x528 frame). Added `vittrack.bbox_inside_image`, which inits with the whole frame on the `tracking/bag` sequence and fails without the fix. `accuracy_vittrack` still passes.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2026-10-19 17:10:31 +03:00
..