This might solve the problem in the miniflann.cpp code, where the Error is located:
Here is the Error again :
error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\flann\src\miniflann.cpp:521: error: (-215:Assertion failed) (size_t)knn <= index_->size() in function ‘cv::flann::runKnnSearch_’.
This might solve it:
#include
#include <opencv2/core.hpp>
#include <opencv2/flann.hpp>
int main() {
// Example data
cv::Mat data(100, 2, CV_32F);
cv::randn(data, cv::Scalar(0), cv::Scalar(1));
// Building the index
cv::flann::IndexParams indexParams;
indexParams.setAlgorithm(cv::flann::FLANN_INDEX_KMEANS);
indexParams.setInt("branching", 4);
indexParams.setInt("iterations", 20);
cv::flann::Index index(data, indexParams, cv::flann::FLANN_DIST_EUCLIDEAN);
// Query point
cv::Mat query(1, 2, CV_32F, cv::Scalar(0.5));
// Check if knn value is greater than index size
int knn = 5;
if (knn > index.size()) {
std::cerr << "Error: knn value exceeds index size." << std::endl;
return -1;
}
// Perform k-NN search
cv::Mat indices, dists;
index.knnSearch(query, indices, dists, knn, cv::flann::SearchParams());
// Print the results
std::cout << "Indices: " << indices << std::endl;
std::cout << "Distances: " << dists << std::endl;
return 0;
}
May you update it please so that I can try it with the stitching_detailed.py code