I have a problem with openCV 2.4.2 flann indexing with AutotunedIndexParams. If i use multiple images to create an index the program exits with the output:
trees : 1
terminate called throwing an exception
Thats a similar error I get for the equal code in JavaCV where the error is the following:
trees : 1
Exception in thread "main" java.lang.RuntimeException: Missing parameter 'algorithm' in the parameters given
at com.googlecode.javacv.cpp.opencv_flann$Index.allocate(Native Method)
at com.googlecode.javacv.cpp.opencv_flann$Index.<init>(opencv_flann.java:229)
In openCVs miniflann.cpp I found multiple lines where p["algorithm"]
is being set, may be that hast something to do with the problem?
For testing here my C++ Code, I'll post the java code as well if needed ;-)
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/flann/flann.hpp>
using namespace cv;
using namespace std;
using namespace flann;
int main( int argc, char** argv ) {
string pathToImages = "/Users/anubis/Desktop/KeypointTest/";
string img_1 = "book_001_canon.jpg";
string img_2 = "book_002_canon.jpg";
string img_3 = "book_003_canon.jpg";
string img_4 = "book_004_canon.jpg";
Mat db_image_1 = imread(pathToImages + img_1, CV_LOAD_IMAGE_COLOR);
Mat db_image_2 = imread(pathToImages + img_2, CV_LOAD_IMAGE_COLOR);
Mat db_image_3 = imread(pathToImages + img_3, CV_LOAD_IMAGE_COLOR);
Mat db_image_4 = imread(pathToImages + img_4, CV_LOAD_IMAGE_COLOR);
vector<KeyPoint> db_keypoints_1;
vector<KeyPoint> db_keypoints_2;
vector<KeyPoint> db_keypoints_3;
vector<KeyPoint> db_keypoints_4;
Mat db_descriptors_1;
Mat db_descriptors_2;
Mat db_descriptors_3;
Mat db_descriptors_4;
Mat db_descriptor;
SurfFeatureDetector detector(400, 4, 2, true, true);
SurfDescriptorExtractor extractor;
detector.detect(db_image_1, db_keypoints_1);
detector.detect(db_image_2, db_keypoints_2);
detector.detect(db_image_3, db_keypoints_3);
detector.detect(db_image_4, db_keypoints_4);
extractor.compute(db_image_1, db_keypoints_1, db_descriptors_1);
extractor.compute(db_image_2, db_keypoints_2, db_descriptors_2);
extractor.compute(db_image_3, db_keypoints_3, db_descriptors_3);
extractor.compute(db_image_4, db_keypoints_4, db_descriptors_4);
db_descriptor.push_back(db_descriptors_1);
db_descriptor.push_back(db_descriptors_2);
db_descriptor.push_back(db_descriptors_3);
db_descriptor.push_back(db_descriptors_4);
IndexParams indexParams = *new AutotunedIndexParams();
Index flannIndex = *new Index(db_descriptor, indexParams);
return 0;
}
The images can be found here: images