Repository navigation
ximgproc: run the RICInterpolator model passes one after another - #4261
Merged
asmorkalov merged 2 commits intoNov 3, 2026
Merged
Conversation
PropagateModels() ran its passes with parallel_for_, but every pass starts from the models the previous pass left in outModels, inLierFlag and bestCost, and all passes share tmpModel and tmpInlierFlag. On more than one thread the passes overwrote each other's data, so the flow changed from run to run and was sometimes far off. InterpolatorTest.RICReferenceAccuracy failed at random because of it. Run the passes in a plain loop. The new test RICSameResultOnAnyNumberOfThreads compares the flow on one thread with the flow on four. Fixes opencv#4260
pctablet505
marked this pull request as ready for review
November 1, 2026 13:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #4260
RICInterpolator::interpolate()returns a different flow on every run when OpenCV uses several threads, and sometimes one far from the reference.PropagateModels()ran its model passes in parallel although each pass builds on the previous one. They now run one after another.Problem
PropagateModels()ran itsiterCntpasses withparallel_for_. Each pass improves the models that the previous pass left inoutModels,inLierFlagandbestCost, and all passes sharetmpModelandtmpInlierFlag, so on several threads the passes overwrite each other. This is whyRICReferenceAccuracyfails now and then, including in the Ubuntu2404-ARM64-FastCV CI job of #4257, which does not touch ximgproc.Changes
forloop. On one thread they run in the same order as before.InterpolatorTest.RICSameResultOnAnyNumberOfThreads: three runs on 4 threads must each match the flow on 1 thread within 0.01 pixel. The limit is not zero because, with the fix, the two flows still differ by about 5e-6 pixel.Tests (x86-64, 32 threads)
RICReferenceAccuracyRICReferenceAccuracytimeAll 473 ximgproc tests pass. The cost is about 8% on 32 threads, because the passes no longer overlap. I could not test on ARM64 or with ThreadSanitizer.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.