mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-12 04:49:50 +08:00
integrating c++17 fixes from #959 (ref:https://github.com/flann-lib/flann/pull/392), fixed pop_t error (https://github.com/flann-lib/flann/commit/b6e37553de0dd47dc8fc9035ba5aef163981b6a4)
This commit is contained in:
@@ -298,6 +298,9 @@ IF(WITH_QT)
|
|||||||
|
|
||||||
# If Qt is here, the GUI will be built
|
# If Qt is here, the GUI will be built
|
||||||
IF(NOT(${VTK_MAJOR_VERSION} LESS 9))
|
IF(NOT(${VTK_MAJOR_VERSION} LESS 9))
|
||||||
|
IF(NOT VTK_QT_VERSION)
|
||||||
|
MESSAGE(FATAL_ERROR "WITH_QT option is ON, but VTK ${VTK_MAJOR_VERSION} has not been built with Qt support, disabling Qt.")
|
||||||
|
ENDIF()
|
||||||
MESSAGE(STATUS "VTK>=9 detected, will use VTK_QT_VERSION=${VTK_QT_VERSION} for Qt version.")
|
MESSAGE(STATUS "VTK>=9 detected, will use VTK_QT_VERSION=${VTK_QT_VERSION} for Qt version.")
|
||||||
IF(${VTK_QT_VERSION} EQUAL 6)
|
IF(${VTK_QT_VERSION} EQUAL 6)
|
||||||
FIND_PACKAGE(Qt6 COMPONENTS Widgets Core Gui OpenGL PrintSupport QUIET OPTIONAL_COMPONENTS Svg)
|
FIND_PACKAGE(Qt6 COMPONENTS Widgets Core Gui OpenGL PrintSupport QUIET OPTIONAL_COMPONENTS Svg)
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ public:
|
|||||||
virtual ~FlannIndex();
|
virtual ~FlannIndex();
|
||||||
|
|
||||||
void release();
|
void release();
|
||||||
unsigned int indexedFeatures() const;
|
size_t indexedFeatures() const;
|
||||||
|
|
||||||
// return Bytes
|
// return Bytes
|
||||||
unsigned long memoryUsed() const;
|
size_t memoryUsed() const;
|
||||||
|
|
||||||
// Note that useDistanceL1 doesn't have any effect if LSH is used
|
// Note that useDistanceL1 doesn't have any effect if LSH is used
|
||||||
void buildLinearIndex(
|
void buildLinearIndex(
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void FlannIndex::release()
|
|||||||
UDEBUG("");
|
UDEBUG("");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FlannIndex::indexedFeatures() const
|
size_t FlannIndex::indexedFeatures() const
|
||||||
{
|
{
|
||||||
if(!index_)
|
if(!index_)
|
||||||
{
|
{
|
||||||
@@ -108,13 +108,13 @@ unsigned int FlannIndex::indexedFeatures() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return Bytes
|
// return Bytes
|
||||||
unsigned long FlannIndex::memoryUsed() const
|
size_t FlannIndex::memoryUsed() const
|
||||||
{
|
{
|
||||||
if(!index_)
|
if(!index_)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
unsigned long memoryUsage = sizeof(FlannIndex);
|
size_t memoryUsage = sizeof(FlannIndex);
|
||||||
memoryUsage += addedDescriptors_.size() * (sizeof(int) + sizeof(cv::Mat) + sizeof(std::map<int, cv::Mat>::iterator)) + sizeof(std::map<int, cv::Mat>);
|
memoryUsage += addedDescriptors_.size() * (sizeof(int) + sizeof(cv::Mat) + sizeof(std::map<int, cv::Mat>::iterator)) + sizeof(std::map<int, cv::Mat>);
|
||||||
memoryUsage += sizeof(std::list<int>) + removedIndexes_.size() * sizeof(int);
|
memoryUsage += sizeof(std::list<int>) + removedIndexes_.size() * sizeof(int);
|
||||||
if(featuresType_ == CV_8UC1)
|
if(featuresType_ == CV_8UC1)
|
||||||
|
|||||||
@@ -324,7 +324,10 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Strict less ordering by name of key only */
|
/** Strict less ordering by name of key only */
|
||||||
struct KeyOrder : std::binary_function<Entry, Entry, bool> {
|
struct KeyOrder {
|
||||||
|
using result_type = bool;
|
||||||
|
using first_argument_type = Entry;
|
||||||
|
using second_argument_type = Entry;
|
||||||
bool operator()(const Entry & lhs, const Entry & rhs) const {
|
bool operator()(const Entry & lhs, const Entry & rhs) const {
|
||||||
const static SI_STRLESS isLess = SI_STRLESS();
|
const static SI_STRLESS isLess = SI_STRLESS();
|
||||||
return isLess(lhs.pItem, rhs.pItem);
|
return isLess(lhs.pItem, rhs.pItem);
|
||||||
@@ -332,7 +335,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Strict less ordering by order, and then name of key */
|
/** Strict less ordering by order, and then name of key */
|
||||||
struct LoadOrder : std::binary_function<Entry, Entry, bool> {
|
struct LoadOrder {
|
||||||
|
using result_type = bool;
|
||||||
|
using first_argument_type = Entry;
|
||||||
|
using second_argument_type = Entry;
|
||||||
bool operator()(const Entry & lhs, const Entry & rhs) const {
|
bool operator()(const Entry & lhs, const Entry & rhs) const {
|
||||||
if (lhs.nOrder != rhs.nOrder) {
|
if (lhs.nOrder != rhs.nOrder) {
|
||||||
return lhs.nOrder < rhs.nOrder;
|
return lhs.nOrder < rhs.nOrder;
|
||||||
|
|||||||
@@ -477,6 +477,10 @@ struct HammingPopcnt
|
|||||||
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
|
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
|
||||||
{
|
{
|
||||||
ResultType result = 0;
|
ResultType result = 0;
|
||||||
|
|
||||||
|
//for portability just use unsigned long -- and use the __builtin_popcountll (see docs for __builtin_popcountll)
|
||||||
|
typedef unsigned long long pop_t;
|
||||||
|
|
||||||
#if __GNUC__
|
#if __GNUC__
|
||||||
#if ANDROID && HAVE_NEON
|
#if ANDROID && HAVE_NEON
|
||||||
static uint64_t features = android_getCpuFeatures();
|
static uint64_t features = android_getCpuFeatures();
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include "rtflann/general.h"
|
#include "rtflann/general.h"
|
||||||
#include "rtflann/algorithms/nn_index.h"
|
#include "rtflann/algorithms/nn_index.h"
|
||||||
@@ -677,7 +678,9 @@ protected:
|
|||||||
/* Construct the randomized trees. */
|
/* Construct the randomized trees. */
|
||||||
for (int i = 0; i < trees_; i++) {
|
for (int i = 0; i < trees_; i++) {
|
||||||
/* Randomize the order of vectors to allow for unbiased sampling. */
|
/* Randomize the order of vectors to allow for unbiased sampling. */
|
||||||
std::random_shuffle(ind.begin(), ind.end());
|
std::random_device rd;
|
||||||
|
std::mt19937 g(rd());
|
||||||
|
std::shuffle(ind.begin(), ind.end(), g);
|
||||||
tree_roots_[i] = divideTree(&ind[0], int(size_) );
|
tree_roots_[i] = divideTree(&ind[0], int(size_) );
|
||||||
}
|
}
|
||||||
delete[] mean_;
|
delete[] mean_;
|
||||||
|
|||||||
@@ -115,8 +115,11 @@ public:
|
|||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CompareT : public std::binary_function<T,T,bool>
|
struct CompareT
|
||||||
{
|
{
|
||||||
|
using result_type = bool;
|
||||||
|
using first_argument_type = T;
|
||||||
|
using second_argument_type = T;
|
||||||
bool operator()(const T& t_1, const T& t_2) const
|
bool operator()(const T& t_1, const T& t_2) const
|
||||||
{
|
{
|
||||||
return t_2 < t_1;
|
return t_2 < t_1;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include "rtflann/util/dynamic_bitset.h"
|
#include "rtflann/util/dynamic_bitset.h"
|
||||||
#include "rtflann/util/matrix.h"
|
#include "rtflann/util/matrix.h"
|
||||||
@@ -364,7 +365,9 @@ inline LshTable<unsigned char>::LshTable(unsigned int feature_size, unsigned int
|
|||||||
// A bit brutal but fast to code
|
// A bit brutal but fast to code
|
||||||
std::vector<size_t> indices(feature_size * CHAR_BIT);
|
std::vector<size_t> indices(feature_size * CHAR_BIT);
|
||||||
for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) indices[i] = i;
|
for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) indices[i] = i;
|
||||||
std::random_shuffle(indices.begin(), indices.end());
|
std::random_device rd;
|
||||||
|
std::mt19937 g(rd());
|
||||||
|
std::shuffle(indices.begin(), indices.end(), g);
|
||||||
|
|
||||||
// Generate a random set of order of subsignature_size_ bits
|
// Generate a random set of order of subsignature_size_ bits
|
||||||
for (unsigned int i = 0; i < key_size_; ++i) {
|
for (unsigned int i = 0; i < key_size_; ++i) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include "rtflann/general.h"
|
#include "rtflann/general.h"
|
||||||
|
|
||||||
@@ -76,13 +77,6 @@ inline int rand_int(int high = RAND_MAX, int low = 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class RandomGenerator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ptrdiff_t operator() (ptrdiff_t i) { return rand_int(i); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Random number generator that returns a distinct number from
|
* Random number generator that returns a distinct number from
|
||||||
* the [0,n) interval each time.
|
* the [0,n) interval each time.
|
||||||
@@ -110,14 +104,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void init(int n)
|
void init(int n)
|
||||||
{
|
{
|
||||||
static RandomGenerator generator;
|
|
||||||
// create and initialize an array of size n
|
// create and initialize an array of size n
|
||||||
vals_.resize(n);
|
vals_.resize(n);
|
||||||
size_ = n;
|
size_ = n;
|
||||||
for (int i = 0; i < size_; ++i) vals_[i] = i;
|
for (int i = 0; i < size_; ++i) vals_[i] = i;
|
||||||
|
|
||||||
// shuffle the elements in the array
|
// shuffle the elements in the array
|
||||||
std::random_shuffle(vals_.begin(), vals_.end(), generator);
|
std::random_device rd;
|
||||||
|
std::mt19937 g(rd());
|
||||||
|
std::shuffle(vals_.begin(), vals_.end(), g);
|
||||||
|
|
||||||
counter_ = 0;
|
counter_ = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user