Crash with the decision tree classifier in OpenCV 3.4.1 and K-fold cross-validations > 1

Description

when training a decision tree classifier in OpenCV 3.4.1 and K-fold cross-validations > 1 (classifier.dt.f > 1), the application crash with the error message

2019-08-01 10:24:30 (FATAL) TrainVectorClassifier: Caught std::exception during application execution: OpenCV(3.4.1) /Datas/Code/OTB/SuperBuild/OPENCV/build/modules/ml/precomp.hpp:157: error: (-213) tree pruning using cross-validation is not implemented.Set CVFolds to 1 in function setCVFolds

Apparently, this bug is already known and "fixed" when defining the classifier.dt.f parameter in otbTrainDecisionTree.hxx:78

  //CVFolds
  AddParameter(ParameterType_Int, "classifier.dt.f", "K-fold cross-validations");
#ifdef OTB_OPENCV_3
  // disable cross validation by default (crash in opencv 3.2)
  SetParameterInt("classifier.dt.f",0);
#else
  SetParameterInt("classifier.dt.f",10);
#endif
  SetParameterDescription("classifier.dt.f",
    "If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K "
    "is equal to cv_folds.");

The default value of the parameter has been set to 0, so it doesn't crash if the parameter is not set, but maybe we should just remove the parameter when using open cv3 if it makes the application crash.

Configuration information

Superbuild (opencv 3.4.1)