I'm am investigating methods on how to speed up an object tracking algorithm that uses local feature matching in each frame of the sequence. I think it would be attractive to use the FLANN kNN neighbor search since a database of descriptors is initialized in the first frame (ie database is not updated), and during every frame the new detected keypoints and descriptors are matched to the database, to attempt to find kNN for each descriptor. It would be attractive to build a tree during initialization and thus during each frame the kNN matching/searching should be significantly faster as we do not traverse the entire database for the given query descriptor's best match, as we have prior knowledge of the search space. However since ORB features are ideal when computing resources are limited, how does one use the FLANN matcher? I have read here that we should convert the descriptors to CV_32F, but also here that this does make sense for binary descriptors to float. What would be the ideal way to use the FLANN matcher with ORB descriptors?
cv::FlannBasedMatcher matcher = cv::FlannBasedMatcher(cv::makePtr<cv::flann::LshIndexParams>(12, 20, 2));
database.convertTo(database32F, CV_32F);
matcher.add(database32F);
matcher.train();
However the error :
Unsupported format or combination of formats (type=5) in buildIndex_, file /home/user/opencv-3.4.0/modules/flann/src/miniflann.cpp, line 315
is produced when I called matcher.train(). What is the correct manner to build the tree in an initialization step?