Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mshabunin
Copy link
Contributor

It seems that random number generator in the TS varies depending on test set being run, e.g. have one seed when single test case is filtered and different seed when whole module is tested. Trying to use cv::theRNG instance in tests.

@mshabunin
Copy link
Contributor Author

Added printouts in one of tests:

TEST_P(Imgproc_BoundingRect_Types, accuracy)
{
const int depth = GetParam();
RNG& rng = ::cvtest::TS::ptr()->get_rng();
for (int k = 0; k < 1000; ++k)
{

Single test, default seed
./bin/opencv_test_imgproc --gtest_filter=Imgproc_BoundingRect_Types.accuracy/0 
...
[ RUN      ] Imgproc_BoundingRect_Types.accuracy/0, where GetParam() = 4
TS::ptr()->get_rng(): 18446744073709551615
theRNG()            : 809564
Single test, modified seed
./bin/opencv_test_imgproc --gtest_filter=Imgproc_BoundingRect_Types.accuracy/0 --test_seed=123 --gtest_random_seed=456
...
[ RUN      ] Imgproc_BoundingRect_Types.accuracy/0, where GetParam() = 4
TS::ptr()->get_rng(): 18446744073709551615
theRNG()            : 123
...
Multiple tests, default seed
./bin/opencv_test_imgproc
...
[ RUN      ] Imgproc_BoundingRect_Types.accuracy/0, where GetParam() = 4
TS::ptr()->get_rng(): 10176101358082286568
theRNG()            : 809564

Perhaps TS::rng doesn't get reset for simple tests (TEST/TEST_P) not inherited from cvtest::BaseTest (old style).

@asmorkalov asmorkalov requested a review from opencv-alalek June 6, 2024 17:01
@mshabunin mshabunin marked this pull request as ready for review June 7, 2024 10:33
@opencv-alalek opencv-alalek added this to the 4.11.0 milestone Jun 7, 2024
@opencv-alalek opencv-alalek self-assigned this Jun 7, 2024
@asmorkalov asmorkalov merged commit 3282954 into opencv:4.x Jun 7, 2024
@mshabunin mshabunin deleted the fix-ts-rng branch June 9, 2024 20:47
@mshabunin mshabunin mentioned this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants