The basic idea of finding pair of corners neighbors is to find best candidate for first corner and check if first corner quite good candidate for its best candidate. And we test first corner for its best candidate less than best candidate for first corner.
Idea of changes is to make finding corner neighbor symmetrical - find best candidate for first corner, find best candidate for second corner and match them as pair iff they are both best candidates for each other.
Additional advantage - it simplifies code and removes some code duplication.
Pull Request Readiness Checklist
The basic idea of finding pair of corners neighbors is to find best candidate for first corner and check if first corner quite good candidate for its best candidate. And we test first corner for its best candidate less than best candidate for first corner.
Idea of changes is to make finding corner neighbor symmetrical - find best candidate for first corner, find best candidate for second corner and match them as pair iff they are both best candidates for each other.
Additional advantage - it simplifies code and removes some code duplication.
I tested this PR with benchmark
There are minor changes in results
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request