Add function setRNGSeed and seed setup in python tests
This commit is contained in:
parent
05384f05cc
commit
a490b64e9b
@ -2170,6 +2170,14 @@ is much faster to use this function to retrieve the generator and then use RNG::
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS RNG& theRNG();
|
CV_EXPORTS RNG& theRNG();
|
||||||
|
|
||||||
|
/** @brief Sets state of default random number generator.
|
||||||
|
|
||||||
|
The function sets state of default random number generator to custom value.
|
||||||
|
@param new state for default random number generator
|
||||||
|
@sa RNG, randu, randn
|
||||||
|
*/
|
||||||
|
CV_EXPORTS_W void setRNGSeed(int seed);
|
||||||
|
|
||||||
/** @brief Generates a single uniformly-distributed random number or an array of random numbers.
|
/** @brief Generates a single uniformly-distributed random number or an array of random numbers.
|
||||||
|
|
||||||
Non-template variant of the function fills the matrix dst with uniformly-distributed
|
Non-template variant of the function fills the matrix dst with uniformly-distributed
|
||||||
|
@ -734,6 +734,12 @@ cv::RNG& cv::theRNG()
|
|||||||
return getCoreTlsData().get()->rng;
|
return getCoreTlsData().get()->rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cv::setRNGSeed(int seed)
|
||||||
|
{
|
||||||
|
getCoreTlsData().get()->rng.state = 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):
|
|||||||
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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user