Train cv::ml::StatModel in opencv 3.0 with weights

asked 2015-05-05 11:25:27 -0500

fedor_v2 gravatar image

I'm trying to train ml::EM to predict skin color on compaq dataset. I have 8e007 skin and 8e008 non-skin pixels, when I try to convert this data to float to put to ml::trainingData program exit with not enough memory. I compressed my data in this way : deleted same pixels and created Mat with number of duplicates of unique pixels. ( example data={1,2,3,4,1,2,4} -> uniqueData={1,2,3,4} + numDuplicates ={2,2,1,2} ). And putted to trainingData unique as samples and numDuplicates as weights of samples. But when I'm training EM using this code :

 Ptr<ml::EM> em = ml::EM::create();
    em->setTermCriteria(TermCriteria( TermCriteria::MAX_ITER+TermCriteria::EPS, 10000, FLT_EPSILON ));
    em->setCovarianceMatrixType( ml::EM::COV_MAT_DIAGONAL);
    em->setClustersNumber(2);
    em->train(trainData);

I's does't use weights that I putted to trainingData

Ptr<ml::TrainData> trainData = ml::TrainData::create(trainSamples, ml::ROW_SAMPLE, trainLables, noArray(),noArray(),trainWeight);

I tryed with weights and without weights in trainData and have same prediction results.

edit retag flag offensive close merge delete