OpenCV Error: Assertion failed (meansFlt.type() == CV_32FC1) in clusterTrainSamples

asked 2017-01-22 13:16:13 -0500

simon gravatar image

I have the following code, using OpenCV 3.1:

std::vector<float> tmp_fg;
(...putting floating point values in tmp_fg...)
Mat fgPixels(tmp_fg.size(), 1, CV_32FC1);

for (int i = 0; i < tmp_fg.size(); ++i)
    float value = tmp_fg[i];<float>(i) = value;       

Ptr<ml::EM> fgGMM = ml::EM::create();


fgGMM->trainEM(fgPixels, noArray(), noArray(), noArray());

When I get to the trainEM(...) line, I have a runtime error (with a dataset of about 44,000 rows):

OpenCV Error: Assertion failed (meansFlt.type() == CV_32FC1) in clusterTrainSamples, file /home/simon/opencv/modules/ml/src/em.cpp, line 421

edit retag flag offensive close merge delete