diff --git a/modules/flann/include/opencv2/flann/dist.h b/modules/flann/include/opencv2/flann/dist.h index 07a1cc29c6..b092b531a1 100644 --- a/modules/flann/include/opencv2/flann/dist.h +++ b/modules/flann/include/opencv2/flann/dist.h @@ -708,7 +708,7 @@ struct KL_Divergence Iterator1 last = a + size; while (a < last) { - if (* b != 0) { + if ( *a != 0 && *b != 0 ) { ResultType ratio = (ResultType)(*a / *b); if (ratio>0) { result += *a * log(ratio); @@ -731,7 +731,7 @@ struct KL_Divergence inline ResultType accum_dist(const U& a, const V& b, int) const { ResultType result = ResultType(); - if( *b != 0 ) { + if( a != 0 && b != 0 ) { ResultType ratio = (ResultType)(a / b); if (ratio>0) { result = a * log(ratio); diff --git a/modules/flann/include/opencv2/flann/kmeans_index.h b/modules/flann/include/opencv2/flann/kmeans_index.h index 7574e7faf8..f743d75224 100644 --- a/modules/flann/include/opencv2/flann/kmeans_index.h +++ b/modules/flann/include/opencv2/flann/kmeans_index.h @@ -650,7 +650,8 @@ private: * * Params: * node = the node to use - * indices = the indices of the points belonging to the node + * indices = array of indices of the points belonging to the node + * indices_length = number of indices in the array */ void computeNodeStatistics(KMeansNodePtr node, int* indices, int indices_length) { @@ -662,7 +663,7 @@ private: memset(mean,0,veclen_*sizeof(DistanceType)); - for (size_t i=0; i diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h index db8b5af946..8f5250171b 100644 --- a/modules/flann/include/opencv2/flann/lsh_table.h +++ b/modules/flann/include/opencv2/flann/lsh_table.h @@ -245,7 +245,7 @@ public: { std::cerr << "LSH is not implemented for that type" << std::endl; assert(0); - return 1; + return 0; } /** Get statistics about the table diff --git a/modules/flann/include/opencv2/flann/result_set.h b/modules/flann/include/opencv2/flann/result_set.h index 735028fb45..02f827ada0 100644 --- a/modules/flann/include/opencv2/flann/result_set.h +++ b/modules/flann/include/opencv2/flann/result_set.h @@ -196,12 +196,10 @@ public: #endif { // Check for duplicate indices - int j = i - 1; - while ((j >= 0) && (dists[j] == dist)) { + for (int j = i; dists[j] == dist && j--;) { if (indices[j] == index) { return; } - --j; } break; }