-
-
Notifications
You must be signed in to change notification settings - Fork 56.3k
Pev fix lsh bad any cast #17640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pev fix lsh bad any cast #17640
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution!
Could you please add simple test case for this? (which triggers this exception)
TEST(Flann_LshTable, regression_bad_any_cast)
{
LshIndexParams params(...);
...
EXPECT_NO_THROW(... check expression ...);
}
Test is useful to avoid similar regressions in the future.
struct LshIndexParams : public IndexParams | ||
{ | ||
LshIndexParams(unsigned int table_number = 12, unsigned int key_size = 20, unsigned int multi_probe_level = 2) | ||
LshIndexParams(int table_number = 12, int key_size = 20, int multi_probe_level = 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do not change constructor parameters (preserve source and ABI compatibility).
I believe we can fix that in this way (without changing of struct fields / constructors):
-(*this)["table_number"] = table_number;
+(*this)["table_number"] = (int)table_number;
- change type for "key_size", "multi_probe_level".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks.
I've made the change to see if this passes the tests now.
Adding the test will be my next task.
int key_size_; | ||
/** How far should we look for neighbors in multi-probe LSH */ | ||
unsigned int multi_probe_level_; | ||
int multi_probe_level_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert these changes too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've squashed all these commits in a new branch "pev--fix-bad-any-cast-in-lsh" based on 3.4. It includes a test.
Finally we don't change any unsigned int for int type for table_number_, key_size_ and multi_probe_level_.
However, as
- in all the others types of IndexParams the types are int and not unsigned int
- and the version of these three parameters in LshIndexParams of miniflann is int and not unsigned int,
I would suggest for consistency to switch to int for master, what is actually done by the "pev-fix-lsh-bad-any-cast" (one dash and not two after pev to easily identify between master based branched and 3.4 based ones)
@pemmanuelviel According to statement from #17684:
lets change (keep from original patch) "int" type for fields. I believe we are ready to merge this PR in the current state. |
@alalek I was not sure you wanted to keep the change. Talking about consistency between uint and int, what do you think about my suggestion to merge PR 17628 on master to change also the LshIndexParams arguments type so they become int
|
@alalek
And for their mapping in miniflann, even LshIndexParams use signed integers. |
@pemmanuelviel Thank you for information! Actually my question was about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contribution!
@alalek Each type of tree has its own set of parameters, with some equivalences for some of them. |
Third commit is omitted due to GitHub todays incident. https://github.com/opencv/opencv/pull/17640/commits/b0315a74a6a91b1446ee56a47b67fe6e675b95ec
Still broken. PR is not marked as merged automatically due GitHub malfunction. Closing... |
closes #17628
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.