mirror of
https://github.com/opencv/opencv.git
synced 2026-07-28 06:43:01 +04:00
4acd2ed6cc
BFMatcher::match() with crossCheck=true previously skipped the OCL dispatch in knnMatchImpl entirely, falling back to CPU even when UMat inputs and an OpenCL device were available. This adds ocl_matchWithCrossCheck() for CV_32FC1 descriptors (e.g. SIFT, SURF): both the forward and reverse nearest-neighbour passes run on the GPU via the existing ocl_matchSingle() kernel, then the cross-check filter runs on the CPU. Only two small index arrays (1×N ints) are downloaded — the O(N²×D) distance work stays on the device. The OCL dispatch in knnMatchImpl is also refactored to unify the Mat/UMat train collection selection before branching on crossCheck. On a NVIDIA RTX 3060 with SIFT descriptors the OCL path is 6–9× faster than CPU at 2k–10k features per image. Binary descriptors (ORB, BRIEF — CV_8U) are unaffected; the existing type guard in ocl_matchSingle keeps them on the CPU path as before. Also adds a correctness test (Features2d_BFMatcher_CrossCheck) and an OCL perf test (BruteForceMatcherFixture/MatchCrossCheck).