Segmentation fault

I am trying to execute based on example code:

  using namespace cv;
  using namespace cv::ml;
  // mat is a Mat containing the features computed beforehand
  Ptr<EM> model = EM::create();
  model->setClustersNumber(static_cast<int>(m_numberClusters));
  Mat logs, labels, probs;
  model->trainEM(mat, logs, labels, probs);

setClustersNumber gives a segmentation fault, if commented out then trainEM does. Debugging reveals, that those are pure virtual functions, which is in coincidence with OpenCV API.

See here:

enter image description here

Nevertheless I do not find any implementation class having those pure virtual functions nor other examples for Expectation Maximization by OpenCV with 3.x.x versions.

enter image description here

enter image description here

related: