mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 00:37:46 +08:00
Fixed Windows build with flann<1.8
This commit is contained in:
+5
-2
@@ -132,8 +132,11 @@ option(WITH_GTSAM "Include GTSAM support" ON)
|
|||||||
option(WITH_CVSBA "Include cvsba support" ON)
|
option(WITH_CVSBA "Include cvsba support" ON)
|
||||||
option(WITH_FLYCAPTURE2 "Include FlyCapture2/Triclops support" ON)
|
option(WITH_FLYCAPTURE2 "Include FlyCapture2/Triclops support" ON)
|
||||||
|
|
||||||
FIND_PACKAGE(FLANN 1.8)
|
find_package(PkgConfig QUIET)
|
||||||
SET(FLANN18_FOUND ${FLANN_FOUND})
|
FIND_PACKAGE(FLANN 1.8 QUIET)
|
||||||
|
IF(PkgConfig_FOUND AND FLANN_FOUND)
|
||||||
|
SET(FLANN18_FOUND TRUE)
|
||||||
|
ENDIF(PkgConfig_FOUND AND FLANN_FOUND)
|
||||||
|
|
||||||
FIND_PACKAGE(OpenCV REQUIRED)
|
FIND_PACKAGE(OpenCV REQUIRED)
|
||||||
FIND_PACKAGE(PCL 1.7 REQUIRED) # Will find FLANN too
|
FIND_PACKAGE(PCL 1.7 REQUIRED) # Will find FLANN too
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ find_package_handle_standard_args(FLANN DEFAULT_MSG FLANN_LIBRARY FLANN_INCLUDE_
|
|||||||
mark_as_advanced(FLANN_LIBRARY FLANN_LIBRARY_DEBUG FLANN_INCLUDE_DIR)
|
mark_as_advanced(FLANN_LIBRARY FLANN_LIBRARY_DEBUG FLANN_INCLUDE_DIR)
|
||||||
|
|
||||||
if(FLANN_FOUND)
|
if(FLANN_FOUND)
|
||||||
message(STATUS "FLANN found (include: ${FLANN_INCLUDE_DIRS}, lib: ${FLANN_LIBRARIES})")
|
IF (NOT FLANN_FIND_QUIETLY)
|
||||||
|
message(STATUS "FLANN found (include: ${FLANN_INCLUDE_DIRS}, lib: ${FLANN_LIBRARIES})")
|
||||||
|
ENDIF (NOT FLANN_FIND_QUIETLY)
|
||||||
if(FLANN_USE_STATIC)
|
if(FLANN_USE_STATIC)
|
||||||
add_definitions(-DFLANN_STATIC)
|
add_definitions(-DFLANN_STATIC)
|
||||||
endif(FLANN_USE_STATIC)
|
endif(FLANN_USE_STATIC)
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ public:
|
|||||||
index_(0),
|
index_(0),
|
||||||
nextIndex_(0),
|
nextIndex_(0),
|
||||||
featuresType_(0),
|
featuresType_(0),
|
||||||
featuresDim_(0)
|
featuresDim_(0),
|
||||||
|
isLSH_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~FlannIndex()
|
virtual ~FlannIndex()
|
||||||
@@ -74,8 +75,20 @@ public:
|
|||||||
{
|
{
|
||||||
if(featuresType_ == CV_8UC1)
|
if(featuresType_ == CV_8UC1)
|
||||||
{
|
{
|
||||||
delete (flann::Index<flann::Hamming<unsigned char> >*)index_;
|
|
||||||
|
#ifdef WITH_FLANN18
|
||||||
|
delete (flann::Index<flann::Hamming<unsigned char> >*)index_;
|
||||||
|
#else
|
||||||
|
// issue with 1.7.1: we should explicitly use the corresponding index
|
||||||
|
if(isLSH_)
|
||||||
|
{
|
||||||
|
delete (flann::LshIndex<flann::Hamming<unsigned char> >*)index_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete (flann::LinearIndex<flann::Hamming<unsigned char> >*)index_;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -84,6 +97,7 @@ public:
|
|||||||
index_ = 0;
|
index_ = 0;
|
||||||
}
|
}
|
||||||
nextIndex_ = 0;
|
nextIndex_ = 0;
|
||||||
|
isLSH_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int indexedFeatures() const
|
unsigned int indexedFeatures() const
|
||||||
@@ -94,8 +108,19 @@ public:
|
|||||||
}
|
}
|
||||||
if(featuresType_ == CV_8UC1)
|
if(featuresType_ == CV_8UC1)
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_FLANN18
|
||||||
return ((const flann::Index<flann::Hamming<unsigned char> >*)index_)->size();
|
return ((const flann::Index<flann::Hamming<unsigned char> >*)index_)->size();
|
||||||
|
#else
|
||||||
|
// issue with 1.7.1: we should explicitly use the corresponding index
|
||||||
|
if(isLSH_)
|
||||||
|
{
|
||||||
|
return ((const flann::LshIndex<flann::Hamming<unsigned char> >*)index_)->size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ((const flann::LinearIndex<flann::Hamming<unsigned char> >*)index_)->size();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -111,9 +136,20 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(featuresType_ == CV_8UC1)
|
if(featuresType_ == CV_8UC1)
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_FLANN18
|
||||||
return ((const flann::Index<flann::Hamming<unsigned char> >*)index_)->usedMemory()/1000;
|
return ((const flann::Index<flann::Hamming<unsigned char> >*)index_)->usedMemory()/1000;
|
||||||
|
#else
|
||||||
|
// issue with 1.7.1: we should explicitly use the corresponding index
|
||||||
|
if(isLSH_)
|
||||||
|
{
|
||||||
|
return ((const flann::LshIndex<flann::Hamming<unsigned char> >*)index_)->usedMemory()/1000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ((const flann::LinearIndex<flann::Hamming<unsigned char> >*)index_)->usedMemory()/1000;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -134,7 +170,21 @@ public:
|
|||||||
if(featuresType_ == CV_8UC1)
|
if(featuresType_ == CV_8UC1)
|
||||||
{
|
{
|
||||||
flann::Matrix<unsigned char> dataset(features.data, features.rows, features.cols);
|
flann::Matrix<unsigned char> dataset(features.data, features.rows, features.cols);
|
||||||
|
#ifdef WITH_FLANN18
|
||||||
index_ = new flann::Index<flann::Hamming<unsigned char> >(dataset, params);
|
index_ = new flann::Index<flann::Hamming<unsigned char> >(dataset, params);
|
||||||
|
#else
|
||||||
|
// issue with 1.7.1: we should explicitly create the corresponding index
|
||||||
|
flann::flann_algorithm_t algo = params.at("algorithm").cast<flann::flann_algorithm_t>();
|
||||||
|
if(algo == flann::FLANN_INDEX_LSH)
|
||||||
|
{
|
||||||
|
isLSH_ = true;
|
||||||
|
index_ = new flann::LshIndex<flann::Hamming<unsigned char> >(dataset, params);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index_ = new flann::LinearIndex<flann::Hamming<unsigned char> >(dataset, params);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
((flann::Index<flann::Hamming<unsigned char> >*)index_)->buildIndex();
|
((flann::Index<flann::Hamming<unsigned char> >*)index_)->buildIndex();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -235,7 +285,19 @@ public:
|
|||||||
{
|
{
|
||||||
flann::Matrix<unsigned int> distsF((unsigned int*)dists.data, dists.rows, dists.cols);
|
flann::Matrix<unsigned int> distsF((unsigned int*)dists.data, dists.rows, dists.cols);
|
||||||
flann::Matrix<unsigned char> queryF(query.data, query.rows, query.cols);
|
flann::Matrix<unsigned char> queryF(query.data, query.rows, query.cols);
|
||||||
|
#ifdef WITH_FLANN18
|
||||||
((flann::Index<flann::Hamming<unsigned char> >*)index_)->knnSearch(queryF, indicesF, distsF, knn, params);
|
((flann::Index<flann::Hamming<unsigned char> >*)index_)->knnSearch(queryF, indicesF, distsF, knn, params);
|
||||||
|
#else
|
||||||
|
// issue with 1.7.1: we should explicitly use the corresponding index
|
||||||
|
if(isLSH_)
|
||||||
|
{
|
||||||
|
((flann::LshIndex<flann::Hamming<unsigned char> >*)index_)->knnSearch(queryF, indicesF, distsF, knn, params);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((flann::LinearIndex<flann::Hamming<unsigned char> >*)index_)->knnSearch(queryF, indicesF, distsF, knn, params);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -250,6 +312,7 @@ private:
|
|||||||
unsigned int nextIndex_;
|
unsigned int nextIndex_;
|
||||||
int featuresType_;
|
int featuresType_;
|
||||||
int featuresDim_;
|
int featuresDim_;
|
||||||
|
bool isLSH_;
|
||||||
};
|
};
|
||||||
|
|
||||||
const int VWDictionary::ID_START = 1;
|
const int VWDictionary::ID_START = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user