C++ error: (-210:Unsupported format or combination of formats) in function 'buildIndex_' > type=0 while using FLANN Library

78 Views Asked by At

I am getting the following error while building FLANN library

terminate called after throwing an instance of 'cv::Exception'
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.5.2) /home/laddu/virtual_env/fomo/tular-irp/example-standalone-inferencing-linux/opencv/opencv/modules/flann/src/miniflann.cpp:336: error: (-210:Unsupported format or combination of formats) in function buildIndex_ > type=0

MY part of code is:

void closest_pattern_match_fomo(vector<Point2f> *prev_detection, vector<Point2f> actual_detection, float x_movement, float y_movement) // finds closest point matches from the previous frame
{
Mat prev_mat(prev_detection->size(), 2, CV_32F);
    for (int i = 0; i < prev_detection->size(); i++) {
        prev_mat.at<float>(i, 0) = static_cast<float>(prev_detection->at(i).x);
        prev_mat.at<float>(i, 1) = static_cast<float>(prev_detection->at(i).y);
    }
    cout<<"PASE1";

// Convert actual detections to a FLANN Matrix
    Mat actual_mat(actual_detection.size(), 2, CV_32F);
    for (int i = 0; i < actual_detection.size(); i++) {
        actual_mat.at<float>(i, 0) = static_cast<float>(actual_detection.at(i).x - x_movement);
        actual_mat.at<float>(i, 1) = static_cast<float>(actual_detection.at(i).y - y_movement);
    }
    flann::Index flann_index(prev_mat.reshape(1), flann::KDTreeIndexParams());
    cout<<"PASE 2";
    Mat indices(actual_mat.rows, 1, CV_32F);
    Mat distances(actual_mat.rows, 1, CV_32F);

    flann_index.knnSearch(actual_mat.reshape(1), indices, distances, 1, flann::SearchParams());
  cout<<"PASE 3";
     for (int i = 0; i < prev_detection->size(); i++) {
        int closest_index = indices.at<int>(i);
        prev_detection->at(i) = actual_detection.at(closest_index);
    }
     cout<<"PASE 4";  
}

Can anyone help me solve the issue?

I tried converting the data in CV_32F but still I am getting this error.

0

There are 0 best solutions below