Skip to content

Commit 8be1ba7

Browse files
committed
features2d: don't use rand(), because it is not thread-safe
Results are not stable with srand()
1 parent 0bd357e commit 8be1ba7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/features2d/src/kaze/AKAZEFeatures.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
20772077
}
20782078
}
20792079

2080-
srand(1024);
2080+
RNG rng(1024);
20812081
Mat_<int> comps = Mat_<int>(nchannels * (int)ceil(nbits / (float)nchannels), 2);
20822082
comps = 1000;
20832083

@@ -2089,7 +2089,7 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
20892089
samples = -1;
20902090

20912091
for (int i = 0; i < npicks; i++) {
2092-
int k = rand() % (fullM.rows - i);
2092+
int k = rng(fullM.rows - i);
20932093
if (i < 6) {
20942094
// Force use of the coarser grid values and comparisons
20952095
k = i;

0 commit comments

Comments
 (0)