Commit 86a72593 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #6343 from terfendail:vt/python_rng_seed_backport

parents 12a8f548 64f02aa7
...@@ -2593,6 +2593,9 @@ CV_EXPORTS_W double kmeans( InputArray data, int K, CV_OUT InputOutputArray best ...@@ -2593,6 +2593,9 @@ CV_EXPORTS_W double kmeans( InputArray data, int K, CV_OUT InputOutputArray best
//! returns the thread-local Random number generator //! returns the thread-local Random number generator
CV_EXPORTS RNG& theRNG(); CV_EXPORTS RNG& theRNG();
//! sets state of the thread-local Random number generator
CV_EXPORTS_W void setRNGSeed(int seed);
//! returns the next unifomly-distributed random number of the specified type //! returns the next unifomly-distributed random number of the specified type
template<typename _Tp> static inline _Tp randu() { return (_Tp)theRNG(); } template<typename _Tp> static inline _Tp randu() { return (_Tp)theRNG(); }
......
...@@ -806,6 +806,11 @@ RNG& theRNG() ...@@ -806,6 +806,11 @@ RNG& theRNG()
} }
void cv::setRNGSeed(int seed)
{
theRNG() = RNG(static_cast<uint64>(seed));
}
void cv::randu(InputOutputArray dst, InputArray low, InputArray high) void cv::randu(InputOutputArray dst, InputArray low, InputArray high)
{ {
theRNG().fill(dst, RNG::UNIFORM, low, high); theRNG().fill(dst, RNG::UNIFORM, low, high);
......
...@@ -42,6 +42,7 @@ class NewOpenCVTests(unittest.TestCase): ...@@ -42,6 +42,7 @@ class NewOpenCVTests(unittest.TestCase):
return self.image_cache[filename] return self.image_cache[filename]
def setUp(self): def setUp(self):
cv2.setRNGSeed(10)
self.image_cache = {} self.image_cache = {}
def hashimg(self, im): def hashimg(self, im):
......
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