Skip to content

Fix mismatch and simplify code in ChessBoardDetector::findQuadNeighbors#24667

Merged
asmorkalov merged 3 commits intoopencv:4.xfrom
MaximSmolskiy:fix-mismatch-and-simplify-code-in-ChessBoardDetector-findQuadNeighbors
Dec 24, 2023
Merged

Fix mismatch and simplify code in ChessBoardDetector::findQuadNeighbors#24667
asmorkalov merged 3 commits intoopencv:4.xfrom
MaximSmolskiy:fix-mismatch-and-simplify-code-in-ChessBoardDetector-findQuadNeighbors

Conversation

@MaximSmolskiy
Copy link
Copy Markdown
Contributor

Pull Request Readiness Checklist

Сode doesn't match comment.
If we want check 1:4 edges ratio and edge_len is squared edge length, then we should check

ediff > 15*edge_len

with constant 15, not 32, because

ediff > 15*edge_len2 <=> edge_len1 - edge_len2 > 15*edge_len2 <=> edge_len1 > 16*edge_len2 <=> 1:4 edges ratio

But for me it's better and simpler to directly check edge_len1 > 16*edge_len2

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Copy link
Copy Markdown
Contributor

@AleksandrPanov AleksandrPanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR was tested with OpenCV synthetic benchmark.

There is no accuracy regressions.
image

👍

Maybe it's better to add this line as a comment?

ediff > 15*edge_len2 <=> edge_len1 - edge_len2 > 15*edge_len2 <=> edge_len1 > 16*edge_len2 <=> 1:4 edges ratio

@MaximSmolskiy
Copy link
Copy Markdown
Contributor Author

Maybe it's better to add this line as a comment?

ediff > 15*edge_len2 <=> edge_len1 - edge_len2 > 15*edge_len2 <=> edge_len1 > 16*edge_len2 <=> 1:4 edges ratio

Added comment

@AleksandrPanov AleksandrPanov removed their assignment Dec 12, 2023
@asmorkalov asmorkalov added this to the 4.9.0 milestone Dec 19, 2023
@MaximSmolskiy
Copy link
Copy Markdown
Contributor Author

@asmorkalov Can you merge this PR please?

@vpisarev
Copy link
Copy Markdown
Contributor

vpisarev commented Dec 22, 2023

The extended testing did not reveal any regressions, so potentially the patch can be integrated. However, maybe it's easier to fix the description rather than change the threshold.

@asmorkalov, @AleksandrPanov, I'd leave the decision to you, since you have more experience with chessboard detector in the past years.

@asmorkalov asmorkalov self-requested a review December 24, 2023 08:43
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov asmorkalov merged commit 4884083 into opencv:4.x Dec 24, 2023
@MaximSmolskiy MaximSmolskiy deleted the fix-mismatch-and-simplify-code-in-ChessBoardDetector-findQuadNeighbors branch December 24, 2023 08:46
@asmorkalov asmorkalov mentioned this pull request Jan 19, 2024
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
…implify-code-in-ChessBoardDetector-findQuadNeighbors

Fix mismatch and simplify code in ChessBoardDetector::findQuadNeighbors opencv#24667

### Pull Request Readiness Checklist

Сode doesn't match comment. 
If we want check `1:4` edges ratio and `edge_len` is squared edge length, then we should check
```
ediff > 15*edge_len
```
with constant `15`, not `32`, because
```
ediff > 15*edge_len2 <=> edge_len1 - edge_len2 > 15*edge_len2 <=> edge_len1 > 16*edge_len2 <=> 1:4 edges ratio
```

But for me it's better and simpler to directly check `edge_len1 > 16*edge_len2`

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants