#include <flann_descriptor_kdtree.h>
|
| std::shared_ptr< flann::Index< flann::L2< double > > > | index_ |
| |
Definition at line 60 of file flann_descriptor_kdtree.h.
| bsfm::FlannDescriptorKDTree::FlannDescriptorKDTree |
( |
| ) |
|
| bsfm::FlannDescriptorKDTree::~FlannDescriptorKDTree |
( |
| ) |
|
Definition at line 44 of file flann_descriptor_kdtree.cpp.
47 for (
size_t ii = 0; ii <
index_->size(); ++ii) {
48 double* descriptor =
index_->getPoint(ii);
std::shared_ptr< flann::Index< flann::L2< double > > > index_
| void bsfm::FlannDescriptorKDTree::AddDescriptor |
( |
Descriptor & |
descriptor | ) |
|
Definition at line 55 of file flann_descriptor_kdtree.cpp.
58 const size_t cols = descriptor.size();
59 flann::Matrix<double> flann_descriptor(
new double[cols], 1, cols);
60 for (
size_t ii = 0; ii < cols; ++ii) {
61 flann_descriptor[0][ii] = descriptor(ii);
67 const int kNumRandomizedKDTrees = 1;
68 index_.reset(
new flann::Index<flann::L2<double> >(
69 flann_descriptor, flann::KDTreeIndexParams(kNumRandomizedKDTrees)));
76 const int kRebuildThreshold = 2;
77 index_->addPoints(flann_descriptor, kRebuildThreshold);
std::shared_ptr< flann::Index< flann::L2< double > > > index_
| void bsfm::FlannDescriptorKDTree::AddDescriptors |
( |
std::vector< Descriptor > & |
descriptors | ) |
|
| bool bsfm::FlannDescriptorKDTree::NearestNeighbor |
( |
Descriptor & |
query, |
|
|
int & |
nn_index, |
|
|
double & |
nn_distance |
|
) |
| |
Definition at line 89 of file flann_descriptor_kdtree.cpp.
92 VLOG(1) <<
"Index has not been built. Descriptors must be added before "
93 "querying the kd tree";
99 flann::Matrix<double> flann_query(query.data(), 1,
index_->veclen());
102 std::vector< std::vector<int> > query_match_indices;
103 std::vector< std::vector<double> > query_distances;
105 const int kOneNearestNeighbor = 1;
106 int num_neighbors_found =
index_->knnSearch(
107 flann_query, query_match_indices, query_distances, kOneNearestNeighbor,
108 flann::SearchParams(flann::FLANN_CHECKS_UNLIMITED) );
111 if (num_neighbors_found > 0) {
112 nn_index = query_match_indices[0][0];
113 nn_distance = query_distances[0][0];
116 return num_neighbors_found > 0;
std::shared_ptr< flann::Index< flann::L2< double > > > index_
| std::shared_ptr< flann::Index<flann::L2<double> > > bsfm::FlannDescriptorKDTree::index_ |
|
private |
The documentation for this class was generated from the following files: