Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

use knnSearch, terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

output error:

  terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

My code:

cvflann::Matrix<uchar> data((uchar*) fetaures.data, fetaures.rows,
        fetaures.cols);
cvflann::Index<cvflann::Hamming<uchar>> flann_index(data,
        cvflann::LshIndexParams(10, 10, 10));
flann_index.buildIndex();

Ptr<ORB> detector = ORB::create(minHessian);
std::vector<cv::KeyPoint> keypoints;
cv::Mat queryDescriptors;
detector->detectAndCompute(Q, noArray(), keypoints, queryDescriptors);
queryDescriptors.convertTo(queryDescriptors, CV_8U);

Mat disMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols), CV_32F);
Mat indeicesMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols),
        CV_32F);
cvflann::Matrix<unsigned char> queries((unsigned char*) queryDescriptors.data,
        queryDescriptors.rows, queryDescriptors.cols);
cvflann::Matrix<int> indices((int*) indeicesMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
cvflann::Matrix<int> dists((int*) disMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
flann_index.knnSearch(queries, indices, dists, knn,
        cvflann::SearchParams(32));

And I found cvflann:index and cv::flann::index, whitch should i use?

use knnSearch, terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

output error:

  terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

My code:

cvflann::Matrix<uchar> data((uchar*) fetaures.data, fetaures.rows,
        fetaures.cols);
cvflann::Index<cvflann::Hamming<uchar>> flann_index(data,
        cvflann::LshIndexParams(10, 10, 10));
flann_index.buildIndex();

Ptr<ORB> detector = ORB::create(minHessian);
std::vector<cv::KeyPoint> keypoints;
cv::Mat queryDescriptors;
detector->detectAndCompute(Q, noArray(), keypoints, queryDescriptors);
queryDescriptors.convertTo(queryDescriptors, CV_8U);

Mat disMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols), CV_32F);
Mat indeicesMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols),
        CV_32F);
cvflann::Matrix<unsigned char> queries((unsigned char*) queryDescriptors.data,
        queryDescriptors.rows, queryDescriptors.cols);
cvflann::Matrix<int> indices((int*) indeicesMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
cvflann::Matrix<int> dists((int*) disMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
flann_index.knnSearch(queries, indices, dists, knn,
        cvflann::SearchParams(32));

And I found cvflann:index and cv::flann::index, whitch should i use?

use knnSearch, terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

output error:

  terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

My code:

cvflann::Matrix<uchar> data((uchar*) fetaures.data, fetaures.rows,
        fetaures.cols);
cvflann::Index<cvflann::Hamming<uchar>> flann_index(data,
        cvflann::LshIndexParams(10, 10, 10));
flann_index.buildIndex();

Ptr<ORB> detector = ORB::create(minHessian);
std::vector<cv::KeyPoint> keypoints;
cv::Mat queryDescriptors;
detector->detectAndCompute(Q, noArray(), keypoints, queryDescriptors);

Mat disMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols), CV_32F);
Mat indeicesMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols),
        CV_32F);
cvflann::Matrix<unsigned char> queries((unsigned char*) queryDescriptors.data,
        queryDescriptors.rows, queryDescriptors.cols);
cvflann::Matrix<int> indices((int*) indeicesMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
cvflann::Matrix<int> dists((int*) disMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
flann_index.knnSearch(queries, indices, dists, knn,
        cvflann::SearchParams(32));

And I found cvflann:index and cv::flann::index, whitch which should i use?

use knnSearch, terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

output error:

  terminate called after throwing an instance of 'cvflann::anyimpl::bad_any_cast'

My code:

cvflann::Matrix<uchar> data((uchar*) fetaures.data, fetaures.rows,
        fetaures.cols);
cvflann::Index<cvflann::Hamming<uchar>> flann_index(data,
        cvflann::LshIndexParams(10, 10, 10));
flann_index.buildIndex();

Ptr<ORB> detector = ORB::create(minHessian);
std::vector<cv::KeyPoint> keypoints;
cv::Mat queryDescriptors;
detector->detectAndCompute(Q, noArray(), keypoints, queryDescriptors);

Mat disMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols), CV_32F);
Mat indeicesMat(cv::Size(queryDescriptors.rows, queryDescriptors.cols),
        CV_32F);
cvflann::Matrix<unsigned char> queries((unsigned char*) queryDescriptors.data,
        queryDescriptors.rows, queryDescriptors.cols);
cvflann::Matrix<int> indices((int*) indeicesMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
cvflann::Matrix<int> dists((int*) disMat.data, queryDescriptors.rows,
        queryDescriptors.cols);
flann_index.knnSearch(queries, indices, dists, knn,
        cvflann::SearchParams(32));

And I found cvflann:index and cv::flann::index, which should i use?