Random Forest setting random seed

Since there is randomness involved in the computation of a random forest classifier, it is necessary to define a random seed to get reproducible results. Is this possible to do in the current implementation of the algorithm (4.1.2 or newer)?

I don’t know if the code supports it now but I found this oldish issue and another question/answer.

please feel encouraged to edit OpenCV source to your liking and submit a pull request.

since this is using the global random generator, you can just seed that:

theRNG().state = 987654321;

I’ve attempted to include that line, as well as setting rng.state = 987654321, however I’m still getting varying results on different runs of training. Do you have any suggestions on what parts of the code I should reset the state?