mirror of
https://github.com/opencv/opencv.git
synced 2026-07-24 04:43:04 +04:00
2b42788803
[video] Add setCoarsestScale to DISOpticalFlow (Fixes #25068) #28217 ### Description This PR addresses issue #25068 regarding the number of scales in `DISOpticalFlow`. Currently, `DISOpticalFlow` automatically computes the `coarsest_scale` based on the image size. While generally effective, this behavior can cause errors in specific use cases (e.g., mechanics/speckle pattern analysis) where high pyramid levels degrade quality. This change introduces a manual override: - Added `setCoarsestScale(int val)` and `getCoarsestScale()` to the public API. - Updated `DISOpticalFlowImpl::calc` and `ocl_calc` to use the user-defined scale if set. - Preserved the existing "automatic" behavior as the default (when set to -1). ### Changes - **`modules/video/include/opencv2/video/tracking.hpp`**: Added virtual method declarations. - **`modules/video/src/dis_flow.cpp`**: Implemented `set/getCoarsestScale` in `DISOpticalFlowImpl` and updated calculation logic. - **`modules/video/test/test_OF_accuracy.cpp`**: Added `DenseOpticalFlow_DIS.ManualCoarsestScale` regression test. Fixes #25068