[opencv] 225/251: features2d: don't use rand(), because it is not thread-safe

Nobuhiro Iwamatsu iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.

commit 8be1ba708e970e67e5d4274d4c12a64757fdb6ff
Author: Alexander Alekhin <alexander.alekhin at intel.com>
Date:   Wed Aug 2 23:48:54 2017 +0300

    features2d: don't use rand(), because it is not thread-safe
    
    Results are not stable with srand()
---
 modules/features2d/src/kaze/AKAZEFeatures.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/features2d/src/kaze/AKAZEFeatures.cpp b/modules/features2d/src/kaze/AKAZEFeatures.cpp
index 39f3d36..14365d3 100644
--- a/modules/features2d/src/kaze/AKAZEFeatures.cpp
+++ b/modules/features2d/src/kaze/AKAZEFeatures.cpp
@@ -2077,7 +2077,7 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
     }
   }
 
-  srand(1024);
+  RNG rng(1024);
   Mat_<int> comps = Mat_<int>(nchannels * (int)ceil(nbits / (float)nchannels), 2);
   comps = 1000;
 
@@ -2089,7 +2089,7 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
   samples = -1;
 
   for (int i = 0; i < npicks; i++) {
-    int k = rand() % (fullM.rows - i);
+    int k = rng(fullM.rows - i);
     if (i < 6) {
       // Force use of the coarser grid values and comparisons
       k = i;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list