FLANN::knnSearch kNN assertion#10549
FLANN::knnSearch kNN assertion#10549opencv-pushbot merged 1 commit intomasterfrom unknown repository
FLANN::knnSearch kNN assertion#10549Conversation
…than the dataset size)
| int dtype = DataType<DistanceType>::type; | ||
| IndexType* index_ = (IndexType*)index; | ||
|
|
||
| CV_Assert((size_t)knn <= index_->size()); |
There was a problem hiding this comment.
There are two main strategies:
- Failure-avoidance
- Set
knn = MIN(knn, index_->size()); - Return NaNs for the additional kNNs.
- Set
- Raise an exception to reject the user input
Is it my imagination, or this is also related to #8300? In that case, I guess the vote for this matter is meaningless, as there are cases where one strategy is better than the other, and vise versa.
In this specific case, the user is expecting a matrix of kNN width, returning smaller one is not a sane choice. Moreover, while returning NaNs in the distance makes sense, the indices matrix needs to be int-type. Accordingly, an exception is the best choice, despite being a fan of failure-avoidance, which does not make sense here.
There was a problem hiding this comment.
#8300 is about an empty cv::Mat as input parameter. Is empty cv::Mat an invalid parameter or not?
This parameters check is fine here.
FLANN::knnSearch garbage bugFLANN::knnSearch kNN assertion
resolves #10548
This pullrequest changes