mirror of
https://github.com/opencv/opencv.git
synced 2026-11-21 00:35:35 -06:00
Add OPTFLOW_FARNEBACK_REUSE_EXPANSION, an opt-in flag set through FarnebackOpticalFlow::setFlags() / create(..., flags). When set, calc() keeps the polynomial expansion of the previous call's next frame and reuses it as the expansion of the following call's prev frame, which saves roughly 9-14% on consecutive-frame sequences. Results are bit-identical with reuse on and off. The flag adds no virtual methods, is ignored by calcOpticalFlowFarneback() and by the OpenCL path, and clearing it or calling collectGarbage() frees the cache. Tests go into test_OF_accuracy.cpp and test_OF_reproducibility.cpp and seed their data from theRNG(). Includes a perf test and a tutorial section. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>