[opencv] 70/98: Backport of setRNGSeed implementation and python test randomness fix
Mattia Rizzolo
mattia at debian.org
Tue Oct 4 17:51:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to annotated tag 2.4.13
in repository opencv.
commit 64f02aa72d730fbf68b33e7b97f13fc2225889ea
Author: Vitaly Tuzov <vitaly.tuzov at itseez.com>
Date: Tue Mar 29 17:59:48 2016 +0300
Backport of setRNGSeed implementation and python test randomness fix
---
modules/core/include/opencv2/core/core.hpp | 3 +++
modules/core/src/rand.cpp | 5 +++++
modules/python/test/tests_common.py | 1 +
3 files changed, 9 insertions(+)
diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp
index 488e3e9..591d50a 100644
--- a/modules/core/include/opencv2/core/core.hpp
+++ b/modules/core/include/opencv2/core/core.hpp
@@ -2593,6 +2593,9 @@ CV_EXPORTS_W double kmeans( InputArray data, int K, CV_OUT InputOutputArray best
//! returns the thread-local Random number generator
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
template<typename _Tp> static inline _Tp randu() { return (_Tp)theRNG(); }
diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp
index 54bb753..73dff18 100644
--- a/modules/core/src/rand.cpp
+++ b/modules/core/src/rand.cpp
@@ -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)
{
theRNG().fill(dst, RNG::UNIFORM, low, high);
diff --git a/modules/python/test/tests_common.py b/modules/python/test/tests_common.py
index 3a636b2..67b5bea 100644
--- a/modules/python/test/tests_common.py
+++ b/modules/python/test/tests_common.py
@@ -42,6 +42,7 @@ class NewOpenCVTests(unittest.TestCase):
return self.image_cache[filename]
def setUp(self):
+ cv2.setRNGSeed(10)
self.image_cache = {}
def hashimg(self, im):
--
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