Commit 4df4a37b authored by Alexander Alekhin's avatar Alexander Alekhin

flann: apply CV_OVERRIDE/CV_FINAL

parent 1ca7ae96
...@@ -54,50 +54,50 @@ struct base_any_policy ...@@ -54,50 +54,50 @@ struct base_any_policy
template<typename T> template<typename T>
struct typed_base_any_policy : base_any_policy struct typed_base_any_policy : base_any_policy
{ {
virtual ::size_t get_size() { return sizeof(T); } virtual ::size_t get_size() CV_OVERRIDE { return sizeof(T); }
virtual const std::type_info& type() { return typeid(T); } virtual const std::type_info& type() CV_OVERRIDE { return typeid(T); }
}; };
template<typename T> template<typename T>
struct small_any_policy : typed_base_any_policy<T> struct small_any_policy CV_FINAL : typed_base_any_policy<T>
{ {
virtual void static_delete(void**) { } virtual void static_delete(void**) CV_OVERRIDE { }
virtual void copy_from_value(void const* src, void** dest) virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE
{ {
new (dest) T(* reinterpret_cast<T const*>(src)); new (dest) T(* reinterpret_cast<T const*>(src));
} }
virtual void clone(void* const* src, void** dest) { *dest = *src; } virtual void clone(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; }
virtual void move(void* const* src, void** dest) { *dest = *src; } virtual void move(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; }
virtual void* get_value(void** src) { return reinterpret_cast<void*>(src); } virtual void* get_value(void** src) CV_OVERRIDE { return reinterpret_cast<void*>(src); }
virtual const void* get_value(void* const * src) { return reinterpret_cast<const void*>(src); } virtual const void* get_value(void* const * src) CV_OVERRIDE { return reinterpret_cast<const void*>(src); }
virtual void print(std::ostream& out, void* const* src) { out << *reinterpret_cast<T const*>(src); } virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast<T const*>(src); }
}; };
template<typename T> template<typename T>
struct big_any_policy : typed_base_any_policy<T> struct big_any_policy CV_FINAL : typed_base_any_policy<T>
{ {
virtual void static_delete(void** x) virtual void static_delete(void** x) CV_OVERRIDE
{ {
if (* x) delete (* reinterpret_cast<T**>(x)); if (* x) delete (* reinterpret_cast<T**>(x));
*x = NULL; *x = NULL;
} }
virtual void copy_from_value(void const* src, void** dest) virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE
{ {
*dest = new T(*reinterpret_cast<T const*>(src)); *dest = new T(*reinterpret_cast<T const*>(src));
} }
virtual void clone(void* const* src, void** dest) virtual void clone(void* const* src, void** dest) CV_OVERRIDE
{ {
*dest = new T(**reinterpret_cast<T* const*>(src)); *dest = new T(**reinterpret_cast<T* const*>(src));
} }
virtual void move(void* const* src, void** dest) virtual void move(void* const* src, void** dest) CV_OVERRIDE
{ {
(*reinterpret_cast<T**>(dest))->~T(); (*reinterpret_cast<T**>(dest))->~T();
**reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src); **reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src);
} }
virtual void* get_value(void** src) { return *src; } virtual void* get_value(void** src) CV_OVERRIDE { return *src; }
virtual const void* get_value(void* const * src) { return *src; } virtual const void* get_value(void* const * src) CV_OVERRIDE { return *src; }
virtual void print(std::ostream& out, void* const* src) { out << *reinterpret_cast<T const*>(*src); } virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast<T const*>(*src); }
}; };
template<> inline void big_any_policy<flann_centers_init_t>::print(std::ostream& out, void* const* src) template<> inline void big_any_policy<flann_centers_init_t>::print(std::ostream& out, void* const* src)
......
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
/** /**
* Method responsible with building the index. * Method responsible with building the index.
*/ */
virtual void buildIndex() virtual void buildIndex() CV_OVERRIDE
{ {
std::ostringstream stream; std::ostringstream stream;
bestParams_ = estimateBuildParams(); bestParams_ = estimateBuildParams();
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
/** /**
* Saves the index to a stream * Saves the index to a stream
*/ */
virtual void saveIndex(FILE* stream) virtual void saveIndex(FILE* stream) CV_OVERRIDE
{ {
save_value(stream, (int)bestIndex_->getType()); save_value(stream, (int)bestIndex_->getType());
bestIndex_->saveIndex(stream); bestIndex_->saveIndex(stream);
...@@ -134,7 +134,7 @@ public: ...@@ -134,7 +134,7 @@ public:
/** /**
* Loads the index from a stream * Loads the index from a stream
*/ */
virtual void loadIndex(FILE* stream) virtual void loadIndex(FILE* stream) CV_OVERRIDE
{ {
int index_type; int index_type;
...@@ -151,7 +151,7 @@ public: ...@@ -151,7 +151,7 @@ public:
/** /**
* Method that searches for nearest-neighbors * Method that searches for nearest-neighbors
*/ */
virtual void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) virtual void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
{ {
int checks = get_param<int>(searchParams,"checks",FLANN_CHECKS_AUTOTUNED); int checks = get_param<int>(searchParams,"checks",FLANN_CHECKS_AUTOTUNED);
if (checks == FLANN_CHECKS_AUTOTUNED) { if (checks == FLANN_CHECKS_AUTOTUNED) {
...@@ -163,7 +163,7 @@ public: ...@@ -163,7 +163,7 @@ public:
} }
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return bestIndex_->getParameters(); return bestIndex_->getParameters();
} }
...@@ -182,7 +182,7 @@ public: ...@@ -182,7 +182,7 @@ public:
/** /**
* Number of features in this index. * Number of features in this index.
*/ */
virtual size_t size() const virtual size_t size() const CV_OVERRIDE
{ {
return bestIndex_->size(); return bestIndex_->size();
} }
...@@ -190,7 +190,7 @@ public: ...@@ -190,7 +190,7 @@ public:
/** /**
* The length of each vector in this index. * The length of each vector in this index.
*/ */
virtual size_t veclen() const virtual size_t veclen() const CV_OVERRIDE
{ {
return bestIndex_->veclen(); return bestIndex_->veclen();
} }
...@@ -198,7 +198,7 @@ public: ...@@ -198,7 +198,7 @@ public:
/** /**
* The amount of memory (in bytes) this index uses. * The amount of memory (in bytes) this index uses.
*/ */
virtual int usedMemory() const virtual int usedMemory() const CV_OVERRIDE
{ {
return bestIndex_->usedMemory(); return bestIndex_->usedMemory();
} }
...@@ -206,7 +206,7 @@ public: ...@@ -206,7 +206,7 @@ public:
/** /**
* Algorithm name * Algorithm name
*/ */
virtual flann_algorithm_t getType() const virtual flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_AUTOTUNED; return FLANN_INDEX_AUTOTUNED;
} }
......
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
/** /**
* @return The index type * @return The index type
*/ */
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_COMPOSITE; return FLANN_INDEX_COMPOSITE;
} }
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
/** /**
* @return Size of the index * @return Size of the index
*/ */
size_t size() const size_t size() const CV_OVERRIDE
{ {
return kdtree_index_->size(); return kdtree_index_->size();
} }
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
/** /**
* \returns The dimensionality of the features in this index. * \returns The dimensionality of the features in this index.
*/ */
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return kdtree_index_->veclen(); return kdtree_index_->veclen();
} }
...@@ -125,7 +125,7 @@ public: ...@@ -125,7 +125,7 @@ public:
/** /**
* \returns The amount of memory (in bytes) used by the index. * \returns The amount of memory (in bytes) used by the index.
*/ */
int usedMemory() const int usedMemory() const CV_OVERRIDE
{ {
return kmeans_index_->usedMemory() + kdtree_index_->usedMemory(); return kmeans_index_->usedMemory() + kdtree_index_->usedMemory();
} }
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
/** /**
* \brief Builds the index * \brief Builds the index
*/ */
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
Logger::info("Building kmeans tree...\n"); Logger::info("Building kmeans tree...\n");
kmeans_index_->buildIndex(); kmeans_index_->buildIndex();
...@@ -145,7 +145,7 @@ public: ...@@ -145,7 +145,7 @@ public:
* \brief Saves the index to a stream * \brief Saves the index to a stream
* \param stream The stream to save the index to * \param stream The stream to save the index to
*/ */
void saveIndex(FILE* stream) void saveIndex(FILE* stream) CV_OVERRIDE
{ {
kmeans_index_->saveIndex(stream); kmeans_index_->saveIndex(stream);
kdtree_index_->saveIndex(stream); kdtree_index_->saveIndex(stream);
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
* \brief Loads the index from a stream * \brief Loads the index from a stream
* \param stream The stream from which the index is loaded * \param stream The stream from which the index is loaded
*/ */
void loadIndex(FILE* stream) void loadIndex(FILE* stream) CV_OVERRIDE
{ {
kmeans_index_->loadIndex(stream); kmeans_index_->loadIndex(stream);
kdtree_index_->loadIndex(stream); kdtree_index_->loadIndex(stream);
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
/** /**
* \returns The index parameters * \returns The index parameters
*/ */
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return index_params_; return index_params_;
} }
...@@ -172,7 +172,7 @@ public: ...@@ -172,7 +172,7 @@ public:
/** /**
* \brief Method that searches for nearest-neighbours * \brief Method that searches for nearest-neighbours
*/ */
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
{ {
kmeans_index_->findNeighbors(result, vec, searchParams); kmeans_index_->findNeighbors(result, vec, searchParams);
kdtree_index_->findNeighbors(result, vec, searchParams); kdtree_index_->findNeighbors(result, vec, searchParams);
......
...@@ -128,7 +128,7 @@ public: ...@@ -128,7 +128,7 @@ public:
/** /**
* Builds the index. * Builds the index.
*/ */
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
if (!loaded_) { if (!loaded_) {
nnIndex_->buildIndex(); nnIndex_->buildIndex();
...@@ -150,7 +150,7 @@ public: ...@@ -150,7 +150,7 @@ public:
* \brief Saves the index to a stream * \brief Saves the index to a stream
* \param stream The stream to save the index to * \param stream The stream to save the index to
*/ */
virtual void saveIndex(FILE* stream) virtual void saveIndex(FILE* stream) CV_OVERRIDE
{ {
nnIndex_->saveIndex(stream); nnIndex_->saveIndex(stream);
} }
...@@ -159,7 +159,7 @@ public: ...@@ -159,7 +159,7 @@ public:
* \brief Loads the index from a stream * \brief Loads the index from a stream
* \param stream The stream from which the index is loaded * \param stream The stream from which the index is loaded
*/ */
virtual void loadIndex(FILE* stream) virtual void loadIndex(FILE* stream) CV_OVERRIDE
{ {
nnIndex_->loadIndex(stream); nnIndex_->loadIndex(stream);
} }
...@@ -167,7 +167,7 @@ public: ...@@ -167,7 +167,7 @@ public:
/** /**
* \returns number of features in this index. * \returns number of features in this index.
*/ */
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return nnIndex_->veclen(); return nnIndex_->veclen();
} }
...@@ -175,7 +175,7 @@ public: ...@@ -175,7 +175,7 @@ public:
/** /**
* \returns The dimensionality of the features in this index. * \returns The dimensionality of the features in this index.
*/ */
size_t size() const size_t size() const CV_OVERRIDE
{ {
return nnIndex_->size(); return nnIndex_->size();
} }
...@@ -183,7 +183,7 @@ public: ...@@ -183,7 +183,7 @@ public:
/** /**
* \returns The index type (kdtree, kmeans,...) * \returns The index type (kdtree, kmeans,...)
*/ */
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return nnIndex_->getType(); return nnIndex_->getType();
} }
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
/** /**
* \returns The amount of memory (in bytes) used by the index. * \returns The amount of memory (in bytes) used by the index.
*/ */
virtual int usedMemory() const virtual int usedMemory() const CV_OVERRIDE
{ {
return nnIndex_->usedMemory(); return nnIndex_->usedMemory();
} }
...@@ -200,7 +200,7 @@ public: ...@@ -200,7 +200,7 @@ public:
/** /**
* \returns The index parameters * \returns The index parameters
*/ */
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return nnIndex_->getParameters(); return nnIndex_->getParameters();
} }
...@@ -213,7 +213,7 @@ public: ...@@ -213,7 +213,7 @@ public:
* \param[in] knn Number of nearest neighbors to return * \param[in] knn Number of nearest neighbors to return
* \param[in] params Search parameters * \param[in] params Search parameters
*/ */
void knnSearch(const Matrix<ElementType>& queries, Matrix<int>& indices, Matrix<DistanceType>& dists, int knn, const SearchParams& params) void knnSearch(const Matrix<ElementType>& queries, Matrix<int>& indices, Matrix<DistanceType>& dists, int knn, const SearchParams& params) CV_OVERRIDE
{ {
nnIndex_->knnSearch(queries, indices, dists, knn, params); nnIndex_->knnSearch(queries, indices, dists, knn, params);
} }
...@@ -227,7 +227,7 @@ public: ...@@ -227,7 +227,7 @@ public:
* \param[in] params Search parameters * \param[in] params Search parameters
* \returns Number of neighbors found * \returns Number of neighbors found
*/ */
int radiusSearch(const Matrix<ElementType>& query, Matrix<int>& indices, Matrix<DistanceType>& dists, float radius, const SearchParams& params) int radiusSearch(const Matrix<ElementType>& query, Matrix<int>& indices, Matrix<DistanceType>& dists, float radius, const SearchParams& params) CV_OVERRIDE
{ {
return nnIndex_->radiusSearch(query, indices, dists, radius, params); return nnIndex_->radiusSearch(query, indices, dists, radius, params);
} }
...@@ -235,7 +235,7 @@ public: ...@@ -235,7 +235,7 @@ public:
/** /**
* \brief Method that searches for nearest-neighbours * \brief Method that searches for nearest-neighbours
*/ */
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
{ {
nnIndex_->findNeighbors(result, vec, searchParams); nnIndex_->findNeighbors(result, vec, searchParams);
} }
......
...@@ -435,7 +435,7 @@ public: ...@@ -435,7 +435,7 @@ public:
/** /**
* Returns size of index. * Returns size of index.
*/ */
size_t size() const size_t size() const CV_OVERRIDE
{ {
return size_; return size_;
} }
...@@ -443,7 +443,7 @@ public: ...@@ -443,7 +443,7 @@ public:
/** /**
* Returns the length of an index feature. * Returns the length of an index feature.
*/ */
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return veclen_; return veclen_;
} }
...@@ -453,7 +453,7 @@ public: ...@@ -453,7 +453,7 @@ public:
* Computes the inde memory usage * Computes the inde memory usage
* Returns: memory used by the index * Returns: memory used by the index
*/ */
int usedMemory() const int usedMemory() const CV_OVERRIDE
{ {
return pool.usedMemory+pool.wastedMemory+memoryCounter; return pool.usedMemory+pool.wastedMemory+memoryCounter;
} }
...@@ -461,7 +461,7 @@ public: ...@@ -461,7 +461,7 @@ public:
/** /**
* Builds the index * Builds the index
*/ */
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
if (branching_<2) { if (branching_<2) {
throw FLANNException("Branching factor must be at least 2"); throw FLANNException("Branching factor must be at least 2");
...@@ -480,13 +480,13 @@ public: ...@@ -480,13 +480,13 @@ public:
} }
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_HIERARCHICAL; return FLANN_INDEX_HIERARCHICAL;
} }
void saveIndex(FILE* stream) void saveIndex(FILE* stream) CV_OVERRIDE
{ {
save_value(stream, branching_); save_value(stream, branching_);
save_value(stream, trees_); save_value(stream, trees_);
...@@ -501,7 +501,7 @@ public: ...@@ -501,7 +501,7 @@ public:
} }
void loadIndex(FILE* stream) void loadIndex(FILE* stream) CV_OVERRIDE
{ {
free_elements(); free_elements();
...@@ -544,7 +544,7 @@ public: ...@@ -544,7 +544,7 @@ public:
* vec = the vector for which to search the nearest neighbors * vec = the vector for which to search the nearest neighbors
* searchParams = parameters that influence the search algorithm (checks) * searchParams = parameters that influence the search algorithm (checks)
*/ */
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
{ {
int maxChecks = get_param(searchParams,"checks",32); int maxChecks = get_param(searchParams,"checks",32);
...@@ -569,7 +569,7 @@ public: ...@@ -569,7 +569,7 @@ public:
} }
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return params; return params;
} }
......
...@@ -120,7 +120,7 @@ public: ...@@ -120,7 +120,7 @@ public:
/** /**
* Builds the index * Builds the index
*/ */
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
/* Construct the randomized trees. */ /* Construct the randomized trees. */
for (int i = 0; i < trees_; i++) { for (int i = 0; i < trees_; i++) {
...@@ -136,13 +136,13 @@ public: ...@@ -136,13 +136,13 @@ public:
} }
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_KDTREE; return FLANN_INDEX_KDTREE;
} }
void saveIndex(FILE* stream) void saveIndex(FILE* stream) CV_OVERRIDE
{ {
save_value(stream, trees_); save_value(stream, trees_);
for (int i=0; i<trees_; ++i) { for (int i=0; i<trees_; ++i) {
...@@ -152,7 +152,7 @@ public: ...@@ -152,7 +152,7 @@ public:
void loadIndex(FILE* stream) void loadIndex(FILE* stream) CV_OVERRIDE
{ {
load_value(stream, trees_); load_value(stream, trees_);
if (tree_roots_!=NULL) { if (tree_roots_!=NULL) {
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
/** /**
* Returns size of index. * Returns size of index.
*/ */
size_t size() const size_t size() const CV_OVERRIDE
{ {
return size_; return size_;
} }
...@@ -178,7 +178,7 @@ public: ...@@ -178,7 +178,7 @@ public:
/** /**
* Returns the length of an index feature. * Returns the length of an index feature.
*/ */
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return veclen_; return veclen_;
} }
...@@ -187,7 +187,7 @@ public: ...@@ -187,7 +187,7 @@ public:
* Computes the inde memory usage * Computes the inde memory usage
* Returns: memory used by the index * Returns: memory used by the index
*/ */
int usedMemory() const int usedMemory() const CV_OVERRIDE
{ {
return int(pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int)); // pool memory and vind array memory return int(pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int)); // pool memory and vind array memory
} }
...@@ -201,7 +201,7 @@ public: ...@@ -201,7 +201,7 @@ public:
* vec = the vector for which to search the nearest neighbors * vec = the vector for which to search the nearest neighbors
* maxCheck = the maximum number of restarts (in a best-bin-first manner) * maxCheck = the maximum number of restarts (in a best-bin-first manner)
*/ */
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
{ {
int maxChecks = get_param(searchParams,"checks", 32); int maxChecks = get_param(searchParams,"checks", 32);
float epsError = 1+get_param(searchParams,"eps",0.0f); float epsError = 1+get_param(searchParams,"eps",0.0f);
...@@ -214,7 +214,7 @@ public: ...@@ -214,7 +214,7 @@ public:
} }
} }
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return index_params_; return index_params_;
} }
......
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
/** /**
* Builds the index * Builds the index
*/ */
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
computeBoundingBox(root_bbox_); computeBoundingBox(root_bbox_);
root_node_ = divideTree(0, (int)size_, root_bbox_ ); // construct the tree root_node_ = divideTree(0, (int)size_, root_bbox_ ); // construct the tree
...@@ -133,13 +133,13 @@ public: ...@@ -133,13 +133,13 @@ public:
} }
} }
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_KDTREE_SINGLE; return FLANN_INDEX_KDTREE_SINGLE;
} }
void saveIndex(FILE* stream) void saveIndex(FILE* stream) CV_OVERRIDE
{ {
save_value(stream, size_); save_value(stream, size_);
save_value(stream, dim_); save_value(stream, dim_);
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
} }
void loadIndex(FILE* stream) void loadIndex(FILE* stream) CV_OVERRIDE
{ {
load_value(stream, size_); load_value(stream, size_);
load_value(stream, dim_); load_value(stream, dim_);
...@@ -179,7 +179,7 @@ public: ...@@ -179,7 +179,7 @@ public:
/** /**
* Returns size of index. * Returns size of index.
*/ */
size_t size() const size_t size() const CV_OVERRIDE
{ {
return size_; return size_;
} }
...@@ -187,7 +187,7 @@ public: ...@@ -187,7 +187,7 @@ public:
/** /**
* Returns the length of an index feature. * Returns the length of an index feature.
*/ */
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return dim_; return dim_;
} }
...@@ -196,7 +196,7 @@ public: ...@@ -196,7 +196,7 @@ public:
* Computes the inde memory usage * Computes the inde memory usage
* Returns: memory used by the index * Returns: memory used by the index
*/ */
int usedMemory() const int usedMemory() const CV_OVERRIDE
{ {
return (int)(pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int)); // pool memory and vind array memory return (int)(pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int)); // pool memory and vind array memory
} }
...@@ -210,7 +210,7 @@ public: ...@@ -210,7 +210,7 @@ public:
* \param[in] knn Number of nearest neighbors to return * \param[in] knn Number of nearest neighbors to return
* \param[in] params Search parameters * \param[in] params Search parameters
*/ */
void knnSearch(const Matrix<ElementType>& queries, Matrix<int>& indices, Matrix<DistanceType>& dists, int knn, const SearchParams& params) void knnSearch(const Matrix<ElementType>& queries, Matrix<int>& indices, Matrix<DistanceType>& dists, int knn, const SearchParams& params) CV_OVERRIDE
{ {
assert(queries.cols == veclen()); assert(queries.cols == veclen());
assert(indices.rows >= queries.rows); assert(indices.rows >= queries.rows);
...@@ -225,7 +225,7 @@ public: ...@@ -225,7 +225,7 @@ public:
} }
} }
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return index_params_; return index_params_;
} }
...@@ -239,7 +239,7 @@ public: ...@@ -239,7 +239,7 @@ public:
* vec = the vector for which to search the nearest neighbors * vec = the vector for which to search the nearest neighbors
* maxCheck = the maximum number of restarts (in a best-bin-first manner) * maxCheck = the maximum number of restarts (in a best-bin-first manner)
*/ */
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
{ {
float epsError = 1+get_param(searchParams,"eps",0.0f); float epsError = 1+get_param(searchParams,"eps",0.0f);
......
...@@ -266,7 +266,7 @@ public: ...@@ -266,7 +266,7 @@ public:
public: public:
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_KMEANS; return FLANN_INDEX_KMEANS;
} }
...@@ -291,7 +291,7 @@ public: ...@@ -291,7 +291,7 @@ public:
{ {
} }
void operator()(const cv::Range& range) const void operator()(const cv::Range& range) const CV_OVERRIDE
{ {
const int begin = range.start; const int begin = range.start;
const int end = range.end; const int end = range.end;
...@@ -398,7 +398,7 @@ public: ...@@ -398,7 +398,7 @@ public:
/** /**
* Returns size of index. * Returns size of index.
*/ */
size_t size() const size_t size() const CV_OVERRIDE
{ {
return size_; return size_;
} }
...@@ -406,7 +406,7 @@ public: ...@@ -406,7 +406,7 @@ public:
/** /**
* Returns the length of an index feature. * Returns the length of an index feature.
*/ */
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return veclen_; return veclen_;
} }
...@@ -421,7 +421,7 @@ public: ...@@ -421,7 +421,7 @@ public:
* Computes the inde memory usage * Computes the inde memory usage
* Returns: memory used by the index * Returns: memory used by the index
*/ */
int usedMemory() const int usedMemory() const CV_OVERRIDE
{ {
return pool_.usedMemory+pool_.wastedMemory+memoryCounter_; return pool_.usedMemory+pool_.wastedMemory+memoryCounter_;
} }
...@@ -429,7 +429,7 @@ public: ...@@ -429,7 +429,7 @@ public:
/** /**
* Builds the index * Builds the index
*/ */
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
if (branching_<2) { if (branching_<2) {
throw FLANNException("Branching factor must be at least 2"); throw FLANNException("Branching factor must be at least 2");
...@@ -448,7 +448,7 @@ public: ...@@ -448,7 +448,7 @@ public:
} }
void saveIndex(FILE* stream) void saveIndex(FILE* stream) CV_OVERRIDE
{ {
save_value(stream, branching_); save_value(stream, branching_);
save_value(stream, iterations_); save_value(stream, iterations_);
...@@ -460,7 +460,7 @@ public: ...@@ -460,7 +460,7 @@ public:
} }
void loadIndex(FILE* stream) void loadIndex(FILE* stream) CV_OVERRIDE
{ {
load_value(stream, branching_); load_value(stream, branching_);
load_value(stream, iterations_); load_value(stream, iterations_);
...@@ -495,7 +495,7 @@ public: ...@@ -495,7 +495,7 @@ public:
* vec = the vector for which to search the nearest neighbors * vec = the vector for which to search the nearest neighbors
* searchParams = parameters that influence the search algorithm (checks, cb_index) * searchParams = parameters that influence the search algorithm (checks, cb_index)
*/ */
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
{ {
int maxChecks = get_param(searchParams,"checks",32); int maxChecks = get_param(searchParams,"checks",32);
...@@ -554,7 +554,7 @@ public: ...@@ -554,7 +554,7 @@ public:
return clusterCount; return clusterCount;
} }
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return index_params_; return index_params_;
} }
......
...@@ -63,47 +63,47 @@ public: ...@@ -63,47 +63,47 @@ public:
LinearIndex(const LinearIndex&); LinearIndex(const LinearIndex&);
LinearIndex& operator=(const LinearIndex&); LinearIndex& operator=(const LinearIndex&);
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_LINEAR; return FLANN_INDEX_LINEAR;
} }
size_t size() const size_t size() const CV_OVERRIDE
{ {
return dataset_.rows; return dataset_.rows;
} }
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return dataset_.cols; return dataset_.cols;
} }
int usedMemory() const int usedMemory() const CV_OVERRIDE
{ {
return 0; return 0;
} }
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
/* nothing to do here for linear search */ /* nothing to do here for linear search */
} }
void saveIndex(FILE*) void saveIndex(FILE*) CV_OVERRIDE
{ {
/* nothing to do here for linear search */ /* nothing to do here for linear search */
} }
void loadIndex(FILE*) void loadIndex(FILE*) CV_OVERRIDE
{ {
/* nothing to do here for linear search */ /* nothing to do here for linear search */
index_params_["algorithm"] = getType(); index_params_["algorithm"] = getType();
} }
void findNeighbors(ResultSet<DistanceType>& resultSet, const ElementType* vec, const SearchParams& /*searchParams*/) void findNeighbors(ResultSet<DistanceType>& resultSet, const ElementType* vec, const SearchParams& /*searchParams*/) CV_OVERRIDE
{ {
ElementType* data = dataset_.data; ElementType* data = dataset_.data;
for (size_t i = 0; i < dataset_.rows; ++i, data += dataset_.cols) { for (size_t i = 0; i < dataset_.rows; ++i, data += dataset_.cols) {
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
} }
} }
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return index_params_; return index_params_;
} }
......
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
/** /**
* Builds the index * Builds the index
*/ */
void buildIndex() void buildIndex() CV_OVERRIDE
{ {
tables_.resize(table_number_); tables_.resize(table_number_);
for (unsigned int i = 0; i < table_number_; ++i) { for (unsigned int i = 0; i < table_number_; ++i) {
...@@ -119,13 +119,13 @@ public: ...@@ -119,13 +119,13 @@ public:
} }
} }
flann_algorithm_t getType() const flann_algorithm_t getType() const CV_OVERRIDE
{ {
return FLANN_INDEX_LSH; return FLANN_INDEX_LSH;
} }
void saveIndex(FILE* stream) void saveIndex(FILE* stream) CV_OVERRIDE
{ {
save_value(stream,table_number_); save_value(stream,table_number_);
save_value(stream,key_size_); save_value(stream,key_size_);
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
save_value(stream, dataset_); save_value(stream, dataset_);
} }
void loadIndex(FILE* stream) void loadIndex(FILE* stream) CV_OVERRIDE
{ {
load_value(stream, table_number_); load_value(stream, table_number_);
load_value(stream, key_size_); load_value(stream, key_size_);
...@@ -151,7 +151,7 @@ public: ...@@ -151,7 +151,7 @@ public:
/** /**
* Returns size of index. * Returns size of index.
*/ */
size_t size() const size_t size() const CV_OVERRIDE
{ {
return dataset_.rows; return dataset_.rows;
} }
...@@ -159,7 +159,7 @@ public: ...@@ -159,7 +159,7 @@ public:
/** /**
* Returns the length of an index feature. * Returns the length of an index feature.
*/ */
size_t veclen() const size_t veclen() const CV_OVERRIDE
{ {
return feature_size_; return feature_size_;
} }
...@@ -168,13 +168,13 @@ public: ...@@ -168,13 +168,13 @@ public:
* Computes the index memory usage * Computes the index memory usage
* Returns: memory used by the index * Returns: memory used by the index
*/ */
int usedMemory() const int usedMemory() const CV_OVERRIDE
{ {
return (int)(dataset_.rows * sizeof(int)); return (int)(dataset_.rows * sizeof(int));
} }
IndexParams getParameters() const IndexParams getParameters() const CV_OVERRIDE
{ {
return index_params_; return index_params_;
} }
...@@ -187,7 +187,7 @@ public: ...@@ -187,7 +187,7 @@ public:
* \param[in] knn Number of nearest neighbors to return * \param[in] knn Number of nearest neighbors to return
* \param[in] params Search parameters * \param[in] params Search parameters
*/ */
virtual void knnSearch(const Matrix<ElementType>& queries, Matrix<int>& indices, Matrix<DistanceType>& dists, int knn, const SearchParams& params) virtual void knnSearch(const Matrix<ElementType>& queries, Matrix<int>& indices, Matrix<DistanceType>& dists, int knn, const SearchParams& params) CV_OVERRIDE
{ {
assert(queries.cols == veclen()); assert(queries.cols == veclen());
assert(indices.rows >= queries.rows); assert(indices.rows >= queries.rows);
...@@ -217,7 +217,7 @@ public: ...@@ -217,7 +217,7 @@ public:
* vec = the vector for which to search the nearest neighbors * vec = the vector for which to search the nearest neighbors
* maxCheck = the maximum number of restarts (in a best-bin-first manner) * maxCheck = the maximum number of restarts (in a best-bin-first manner)
*/ */
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& /*searchParams*/) void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& /*searchParams*/) CV_OVERRIDE
{ {
getNeighbors(vec, result); getNeighbors(vec, result);
} }
......
...@@ -109,13 +109,13 @@ public: ...@@ -109,13 +109,13 @@ public:
return count; return count;
} }
bool full() const bool full() const CV_OVERRIDE
{ {
return count == capacity; return count == capacity;
} }
void addPoint(DistanceType dist, int index) void addPoint(DistanceType dist, int index) CV_OVERRIDE
{ {
if (dist >= worst_distance_) return; if (dist >= worst_distance_) return;
int i; int i;
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
worst_distance_ = dists[capacity-1]; worst_distance_ = dists[capacity-1];
} }
DistanceType worstDist() const DistanceType worstDist() const CV_OVERRIDE
{ {
return worst_distance_; return worst_distance_;
} }
...@@ -176,13 +176,13 @@ public: ...@@ -176,13 +176,13 @@ public:
return count; return count;
} }
bool full() const bool full() const CV_OVERRIDE
{ {
return count == capacity; return count == capacity;
} }
void addPoint(DistanceType dist, int index) void addPoint(DistanceType dist, int index) CV_OVERRIDE
{ {
if (dist >= worst_distance_) return; if (dist >= worst_distance_) return;
int i; int i;
...@@ -215,7 +215,7 @@ public: ...@@ -215,7 +215,7 @@ public:
worst_distance_ = dists[capacity-1]; worst_distance_ = dists[capacity-1];
} }
DistanceType worstDist() const DistanceType worstDist() const CV_OVERRIDE
{ {
return worst_distance_; return worst_distance_;
} }
...@@ -310,7 +310,7 @@ public: ...@@ -310,7 +310,7 @@ public:
/** Check the status of the set /** Check the status of the set
* @return true if we have k NN * @return true if we have k NN
*/ */
inline bool full() const inline bool full() const CV_OVERRIDE
{ {
return is_full_; return is_full_;
} }
...@@ -365,7 +365,7 @@ public: ...@@ -365,7 +365,7 @@ public:
* If we don't have enough neighbors, it returns the max possible value * If we don't have enough neighbors, it returns the max possible value
* @return * @return
*/ */
inline DistanceType worstDist() const inline DistanceType worstDist() const CV_OVERRIDE
{ {
return worst_distance_; return worst_distance_;
} }
...@@ -402,7 +402,7 @@ public: ...@@ -402,7 +402,7 @@ public:
* @param dist distance for that neighbor * @param dist distance for that neighbor
* @param index index of that neighbor * @param index index of that neighbor
*/ */
inline void addPoint(DistanceType dist, int index) inline void addPoint(DistanceType dist, int index) CV_OVERRIDE
{ {
// Don't do anything if we are worse than the worst // Don't do anything if we are worse than the worst
if (dist >= worst_distance_) return; if (dist >= worst_distance_) return;
...@@ -422,7 +422,7 @@ public: ...@@ -422,7 +422,7 @@ public:
/** Remove all elements in the set /** Remove all elements in the set
*/ */
void clear() void clear() CV_OVERRIDE
{ {
dist_indices_.clear(); dist_indices_.clear();
worst_distance_ = std::numeric_limits<DistanceType>::max(); worst_distance_ = std::numeric_limits<DistanceType>::max();
...@@ -461,14 +461,14 @@ public: ...@@ -461,14 +461,14 @@ public:
* @param dist distance for that neighbor * @param dist distance for that neighbor
* @param index index of that neighbor * @param index index of that neighbor
*/ */
void addPoint(DistanceType dist, int index) void addPoint(DistanceType dist, int index) CV_OVERRIDE
{ {
if (dist <= radius_) dist_indices_.insert(DistIndex(dist, index)); if (dist <= radius_) dist_indices_.insert(DistIndex(dist, index));
} }
/** Remove all elements in the set /** Remove all elements in the set
*/ */
inline void clear() inline void clear() CV_OVERRIDE
{ {
dist_indices_.clear(); dist_indices_.clear();
} }
...@@ -477,7 +477,7 @@ public: ...@@ -477,7 +477,7 @@ public:
/** Check the status of the set /** Check the status of the set
* @return alwys false * @return alwys false
*/ */
inline bool full() const inline bool full() const CV_OVERRIDE
{ {
return true; return true;
} }
...@@ -486,7 +486,7 @@ public: ...@@ -486,7 +486,7 @@ public:
* If we don't have enough neighbors, it returns the max possible value * If we don't have enough neighbors, it returns the max possible value
* @return * @return
*/ */
inline DistanceType worstDist() const inline DistanceType worstDist() const CV_OVERRIDE
{ {
return radius_; return radius_;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment