diff --git a/modules/flann/include/opencv2/flann/autotuned_index.h b/modules/flann/include/opencv2/flann/autotuned_index.h index eb4554f077..54a60a73d6 100644 --- a/modules/flann/include/opencv2/flann/autotuned_index.h +++ b/modules/flann/include/opencv2/flann/autotuned_index.h @@ -497,7 +497,7 @@ private: const int nn = 1; const size_t SAMPLE_COUNT = 1000; - assert(bestIndex_ != NULL); // must have a valid index + CV_Assert(bestIndex_ != NULL && "Requires a valid index"); // must have a valid index float speedup = 0; diff --git a/modules/flann/include/opencv2/flann/flann_base.hpp b/modules/flann/include/opencv2/flann/flann_base.hpp index 83606d232f..641fdb01e2 100644 --- a/modules/flann/include/opencv2/flann/flann_base.hpp +++ b/modules/flann/include/opencv2/flann/flann_base.hpp @@ -34,7 +34,6 @@ //! @cond IGNORED #include -#include #include #include "general.h" diff --git a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h index d830bc6a00..a52166d3c4 100644 --- a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h +++ b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h @@ -35,7 +35,6 @@ #include #include -#include #include #include @@ -153,7 +152,7 @@ private: int n = indices_length; int rnd = rand_int(n); - assert(rnd >=0 && rnd < n); + CV_DbgAssert(rnd >=0 && rnd < n); centers[0] = dsindices[rnd]; @@ -208,7 +207,7 @@ private: // Choose one random center and set the closestDistSq values int index = rand_int(n); - assert(index >=0 && index < n); + CV_DbgAssert(index >=0 && index < n); centers[0] = dsindices[index]; // Computing distance^2 will have the advantage of even higher probability further to pick new centers @@ -295,7 +294,7 @@ private: // Choose one random center and set the closestDistSq values int index = rand_int(n); - assert(index >=0 && index < n); + CV_DbgAssert(index >=0 && index < n); centers[0] = dsindices[index]; for (int i = 0; i < n; i++) { @@ -564,10 +563,10 @@ public: NodePtr node = branch.node; findNN(node, result, vec, checks, maxChecks, heap, checked); } - assert(result.full()); delete heap; + CV_Assert(result.full()); } IndexParams getParameters() const CV_OVERRIDE diff --git a/modules/flann/include/opencv2/flann/index_testing.h b/modules/flann/include/opencv2/flann/index_testing.h index 47b6f0b86f..f3d147588d 100644 --- a/modules/flann/include/opencv2/flann/index_testing.h +++ b/modules/flann/include/opencv2/flann/index_testing.h @@ -34,7 +34,6 @@ //! @cond IGNORED #include -#include #include #include "matrix.h" diff --git a/modules/flann/include/opencv2/flann/kdtree_index.h b/modules/flann/include/opencv2/flann/kdtree_index.h index 472350516f..acc87a3198 100644 --- a/modules/flann/include/opencv2/flann/kdtree_index.h +++ b/modules/flann/include/opencv2/flann/kdtree_index.h @@ -35,7 +35,6 @@ #include #include -#include #include #include "general.h" @@ -433,7 +432,7 @@ private: if (trees_>0) { searchLevelExact(result, vec, tree_roots_[0], 0.0, epsError); } - assert(result.full()); + CV_Assert(result.full()); } /** @@ -462,7 +461,7 @@ private: delete heap; - assert(result.full()); + CV_Assert(result.full()); } diff --git a/modules/flann/include/opencv2/flann/kdtree_single_index.h b/modules/flann/include/opencv2/flann/kdtree_single_index.h index ce4c1c5b7e..e571403b10 100644 --- a/modules/flann/include/opencv2/flann/kdtree_single_index.h +++ b/modules/flann/include/opencv2/flann/kdtree_single_index.h @@ -35,7 +35,6 @@ #include #include -#include #include #include "general.h" @@ -214,11 +213,11 @@ public: */ void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE { - assert(queries.cols == veclen()); - assert(indices.rows >= queries.rows); - assert(dists.rows >= queries.rows); - assert(int(indices.cols) >= knn); - assert(int(dists.cols) >= knn); + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); KNNSimpleResultSet resultSet(knn); for (size_t i = 0; i < queries.rows; i++) { diff --git a/modules/flann/include/opencv2/flann/kmeans_index.h b/modules/flann/include/opencv2/flann/kmeans_index.h index 695ef6e8b1..475f79b66a 100644 --- a/modules/flann/include/opencv2/flann/kmeans_index.h +++ b/modules/flann/include/opencv2/flann/kmeans_index.h @@ -35,7 +35,6 @@ #include #include -#include #include #include @@ -152,7 +151,7 @@ public: int n = indices_length; int rnd = rand_int(n); - assert(rnd >=0 && rnd < n); + CV_DbgAssert(rnd >=0 && rnd < n); centers[0] = indices[rnd]; @@ -207,7 +206,7 @@ public: // Choose one random center and set the closestDistSq values int index = rand_int(n); - assert(index >=0 && index < n); + CV_DbgAssert(index >=0 && index < n); centers[0] = indices[index]; for (int i = 0; i < n; i++) { @@ -502,9 +501,9 @@ public: KMeansNodePtr node = branch.node; findNN(node, result, vec, checks, maxChecks, heap); } - assert(result.full()); - delete heap; + + CV_Assert(result.full()); } } diff --git a/modules/flann/include/opencv2/flann/lsh_index.h b/modules/flann/include/opencv2/flann/lsh_index.h index 86c0654051..9ac30136ff 100644 --- a/modules/flann/include/opencv2/flann/lsh_index.h +++ b/modules/flann/include/opencv2/flann/lsh_index.h @@ -38,7 +38,6 @@ //! @cond IGNORED #include -#include #include #include #include @@ -53,6 +52,11 @@ #include "random.h" #include "saving.h" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) //disable unreachable code +#endif + namespace cvflann { @@ -191,11 +195,11 @@ public: */ virtual void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE { - assert(queries.cols == veclen()); - assert(indices.rows >= queries.rows); - assert(dists.rows >= queries.rows); - assert(int(indices.cols) >= knn); - assert(int(dists.cols) >= knn); + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); KNNUniqueResultSet resultSet(knn); @@ -391,6 +395,10 @@ private: }; } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + //! @endcond #endif //OPENCV_FLANN_LSH_INDEX_H_ diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h index 8f5250171b..a189562d3a 100644 --- a/modules/flann/include/opencv2/flann/lsh_table.h +++ b/modules/flann/include/opencv2/flann/lsh_table.h @@ -58,6 +58,12 @@ #include "dynamic_bitset.h" #include "matrix.h" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) //disable unreachable code +#endif + + namespace cvflann { @@ -162,8 +168,7 @@ public: { feature_size_ = feature_size; CV_UNUSED(key_size); - std::cerr << "LSH is not implemented for that type" << std::endl; - assert(0); + CV_Error(cv::Error::StsUnsupportedFormat, "LSH is not implemented for that type" ); } /** Add a feature to the table @@ -243,8 +248,7 @@ public: */ size_t getKey(const ElementType* /*feature*/) const { - std::cerr << "LSH is not implemented for that type" << std::endl; - assert(0); + CV_Error(cv::Error::StsUnsupportedFormat, "LSH is not implemented for that type" ); return 0; } @@ -510,6 +514,10 @@ inline LshStats LshTable::getStats() const } } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //! @endcond diff --git a/modules/flann/include/opencv2/flann/nn_index.h b/modules/flann/include/opencv2/flann/nn_index.h index 00fe6ec5ae..fbb4c7924c 100644 --- a/modules/flann/include/opencv2/flann/nn_index.h +++ b/modules/flann/include/opencv2/flann/nn_index.h @@ -69,11 +69,11 @@ public: */ virtual void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) { - assert(queries.cols == veclen()); - assert(indices.rows >= queries.rows); - assert(dists.rows >= queries.rows); - assert(int(indices.cols) >= knn); - assert(int(dists.cols) >= knn); + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); #if 0 KNNResultSet resultSet(knn); diff --git a/modules/flann/include/opencv2/flann/simplex_downhill.h b/modules/flann/include/opencv2/flann/simplex_downhill.h index 20b7e03c92..02970148b2 100644 --- a/modules/flann/include/opencv2/flann/simplex_downhill.h +++ b/modules/flann/include/opencv2/flann/simplex_downhill.h @@ -72,7 +72,7 @@ float optimizeSimplexDownhill(T* points, int n, F func, float* vals = NULL ) { const int MAX_ITERATIONS = 10; - assert(n>0); + CV_DbgAssert(n>0); T* p_o = new T[n]; T* p_r = new T[n];