10 #ifndef mrpt_vision_descriptor_pairing_H    11 #define mrpt_vision_descriptor_pairing_H    48                 template <
class DESCRIPTOR_KDTREE>
    50                         std::vector<vector_size_t>             * pairings_1_to_multi_2, 
    51                         std::vector<std::pair<size_t,size_t> > * pairings_1_to_2,
    53                         const DESCRIPTOR_KDTREE                & feats_img2_kdtree,
    55                         const size_t                             max_neighbors = 4, 
    56                         const double                             max_relative_distance = 1.2,
    57                         const typename DESCRIPTOR_KDTREE::kdtree_t::DistanceType max_distance = std::numeric_limits<typename DESCRIPTOR_KDTREE::kdtree_t::DistanceType>::max()
    62                         ASSERT_(pairings_1_to_multi_2!=NULL || pairings_1_to_2!=NULL)
    64                         typedef typename DESCRIPTOR_KDTREE::kdtree_t::ElementType   KDTreeElementType; 
    65                         typedef typename DESCRIPTOR_KDTREE::kdtree_t::DistanceType  KDTreeDistanceType; 
    67                         const size_t N=feats_img1.
size();
    68                         if (pairings_1_to_multi_2) pairings_1_to_multi_2->assign(N, 
vector_size_t()); 
    69                         if (pairings_1_to_2) { pairings_1_to_2->clear(); pairings_1_to_2->reserve(N); }
    71                         size_t overall_pairs = 0;
    73                         if (!N) 
return overall_pairs; 
    76                                 ASSERTMSG_(feats_img1[0]->descriptors.hasDescriptorSIFT(), 
"Request to match SIFT features but feats_img1 has no SIFT descriptors!")
    77                                 ASSERTMSG_(
sizeof(KDTreeElementType)==
sizeof(feats_img1[0]->descriptors.SIFT[0]),
"Incorrect data type kd_tree::ElementType for SIFT (should be uint8_t)")
    80                                 ASSERTMSG_(feats_img1[0]->descriptors.hasDescriptorSURF(), 
"Request to match SURF features but feats_img1 has no SURF descriptors!")
    81                                 ASSERTMSG_(
sizeof(KDTreeElementType)==
sizeof(feats_img1[0]->descriptors.SURF[0]),
"Incorrect data type kd_tree::ElementType for SURF (should be float)")
    83                         else { 
THROW_EXCEPTION(
"This function only supports SIFT or SURFT descriptors") }
    85                         std::vector<size_t> 
indices(max_neighbors);
    86                         std::vector<double> distances(max_neighbors);
    88                         for (
size_t i=0;i<N;i++)
    92                                 const void * ptr_query;
    94                                 else if (descriptor==
descSURF) ptr_query = &descs.
SURF[0];
    96                                 feats_img2_kdtree.get_kdtree().knnSearch(
    97                                         static_cast<const KDTreeElementType*>( ptr_query ), 
   103                                 const KDTreeDistanceType this_thresh = 
std::min( max_relative_distance*distances[0], max_distance);
   104                                 for (
size_t j=0;j<max_neighbors;j++)
   106                                         if (distances[j]<=this_thresh) {
   108                                                 if (pairings_1_to_multi_2) (*pairings_1_to_multi_2)[i].push_back(
indices[j]);
   109                                                 if (pairings_1_to_2) pairings_1_to_2->push_back(std::make_pair(i,
indices[j]));
   114                         return overall_pairs;
 size_t find_descriptor_pairings(std::vector< vector_size_t > *pairings_1_to_multi_2, std::vector< std::pair< size_t, size_t > > *pairings_1_to_2, const CFeatureList &feats_img1, const DESCRIPTOR_KDTREE &feats_img2_kdtree, const mrpt::vision::TDescriptorType descriptor=descSIFT, const size_t max_neighbors=4, const double max_relative_distance=1.2, const typename DESCRIPTOR_KDTREE::kdtree_t::DistanceType max_distance=std::numeric_limits< typename DESCRIPTOR_KDTREE::kdtree_t::DistanceType >::max())
Search for pairings between two sets of visual descriptors (for now, only SURF and SIFT features are ...
 
#define THROW_EXCEPTION(msg)
 
GLuint GLuint GLsizei GLenum const GLvoid * indices
 
std::vector< float > SURF
SURF feature descriptor. 
 
std::vector< uint8_t > SIFT
SIFT feature descriptor. 
 
All the possible descriptors this feature may have. 
 
A list of visual features, to be used as output by detectors, as input/output by trackers, etc. 
 
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
#define ASSERT_ABOVEEQ_(__A, __B)
 
std::vector< size_t > vector_size_t
 
#define ASSERTMSG_(f, __ERROR_MSG)