mirror of
https://github.com/opencv/opencv.git
synced 2026-11-22 17:33:41 -06:00
video: clear stale initial flow in DISOpticalFlow::calc() 🤖🤖🤖 - #30860 Fixes #30857 `DISOpticalFlow::calc()` kept the initial-flow pyramid of an earlier call, so a later call without an initial flow still used it, or read past it when the frame grew. ### Change - Clear `initial_Ux` and `initial_Uy` in `prepareBuffers()` when no initial flow is given. - The OpenCL path is unchanged: it never reads an initial flow. ### Tests `DenseOpticalFlow_DIS.StaleInitialFlow` gives one object an initial flow, then calls it without one, on the same frame and on a larger one, and compares with a fresh object (`NORM_INF == 0`). | Check (Linux x86-64, GCC 15.2, with opencv_extra) | 4.x | This PR | |---|---|---| | new test | fails, then segfaults on the larger frame | passes, 4 seeds | | clear removed | | fails, then segfaults | | larger frame under AddressSanitizer | heap-buffer-overflow | no report | | `opencv_test_video`, 178 existing tests | 8 failures (GOTURN model, data) | same 8 | 5.x has the same code; the change merges cleanly. Not run on Windows or macOS. Prepared with an AI assistant; every result was reproduced by running the code. ### 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