Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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];
    fgPixels.at<float>(i) = value;       
}

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

fgGMM->setClustersNumber(1);

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