2011-02-10 04:55:11 +08:00
|
|
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
|
|
//
|
|
|
|
// By downloading, copying, installing or using the software you agree to this license.
|
|
|
|
// If you do not agree to this license, do not download, install,
|
|
|
|
// copy or use the software.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Intel License Agreement
|
|
|
|
// For Open Source Computer Vision Library
|
|
|
|
//
|
|
|
|
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
|
|
// Third party copyrights are property of their respective owners.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
// are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistribution's of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
|
|
// derived from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// This software is provided by the copyright holders and contributors "as is" and
|
|
|
|
// any express or implied warranties, including, but not limited to, the implied
|
|
|
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
|
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
|
|
// indirect, incidental, special, exemplary, or consequential damages
|
|
|
|
// (including, but not limited to, procurement of substitute goods or services;
|
|
|
|
// loss of use, data, or profits; or business interruption) however caused
|
|
|
|
// and on any theory of liability, whether in contract, strict liability,
|
|
|
|
// or tort (including negligence or otherwise) arising in any way out of
|
|
|
|
// the use of this software, even if advised of the possibility of such damage.
|
|
|
|
//
|
|
|
|
//M*/
|
|
|
|
|
|
|
|
#include "test_precomp.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
2014-07-30 03:54:23 +08:00
|
|
|
using cv::ml::TrainData;
|
|
|
|
using cv::ml::EM;
|
|
|
|
using cv::ml::KNearest;
|
2011-02-10 04:55:11 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
static
|
|
|
|
void defaultDistribs( Mat& means, vector<Mat>& covs, int type=CV_32FC1 )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
|
|
|
float mp0[] = {0.0f, 0.0f}, cp0[] = {0.67f, 0.0f, 0.0f, 0.67f};
|
|
|
|
float mp1[] = {5.0f, 0.0f}, cp1[] = {1.0f, 0.0f, 0.0f, 1.0f};
|
|
|
|
float mp2[] = {1.0f, 5.0f}, cp2[] = {1.0f, 0.0f, 0.0f, 1.0f};
|
2012-04-14 05:50:59 +08:00
|
|
|
means.create(3, 2, type);
|
2011-02-10 04:55:11 +08:00
|
|
|
Mat m0( 1, 2, CV_32FC1, mp0 ), c0( 2, 2, CV_32FC1, cp0 );
|
|
|
|
Mat m1( 1, 2, CV_32FC1, mp1 ), c1( 2, 2, CV_32FC1, cp1 );
|
|
|
|
Mat m2( 1, 2, CV_32FC1, mp2 ), c2( 2, 2, CV_32FC1, cp2 );
|
|
|
|
means.resize(3), covs.resize(3);
|
2012-04-14 05:50:59 +08:00
|
|
|
|
|
|
|
Mat mr0 = means.row(0);
|
|
|
|
m0.convertTo(mr0, type);
|
|
|
|
c0.convertTo(covs[0], type);
|
|
|
|
|
|
|
|
Mat mr1 = means.row(1);
|
|
|
|
m1.convertTo(mr1, type);
|
|
|
|
c1.convertTo(covs[1], type);
|
|
|
|
|
|
|
|
Mat mr2 = means.row(2);
|
|
|
|
m2.convertTo(mr2, type);
|
|
|
|
c2.convertTo(covs[2], type);
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// generate points sets by normal distributions
|
2012-04-14 05:50:59 +08:00
|
|
|
static
|
|
|
|
void generateData( Mat& data, Mat& labels, const vector<int>& sizes, const Mat& _means, const vector<Mat>& covs, int dataType, int labelType )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
|
|
|
vector<int>::const_iterator sit = sizes.begin();
|
|
|
|
int total = 0;
|
|
|
|
for( ; sit != sizes.end(); ++sit )
|
|
|
|
total += *sit;
|
2012-04-14 05:50:59 +08:00
|
|
|
CV_Assert( _means.rows == (int)sizes.size() && covs.size() == sizes.size() );
|
|
|
|
CV_Assert( !data.empty() && data.rows == total );
|
|
|
|
CV_Assert( data.type() == dataType );
|
2012-06-09 23:00:04 +08:00
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
labels.create( data.rows, 1, labelType );
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
randn( data, Scalar::all(-1.0), Scalar::all(1.0) );
|
|
|
|
vector<Mat> means(sizes.size());
|
|
|
|
for(int i = 0; i < _means.rows; i++)
|
|
|
|
means[i] = _means.row(i);
|
2011-02-10 04:55:11 +08:00
|
|
|
vector<Mat>::const_iterator mit = means.begin(), cit = covs.begin();
|
|
|
|
int bi, ei = 0;
|
|
|
|
sit = sizes.begin();
|
|
|
|
for( int p = 0, l = 0; sit != sizes.end(); ++sit, ++mit, ++cit, l++ )
|
|
|
|
{
|
|
|
|
bi = ei;
|
|
|
|
ei = bi + *sit;
|
|
|
|
assert( mit->rows == 1 && mit->cols == data.cols );
|
|
|
|
assert( cit->rows == data.cols && cit->cols == data.cols );
|
|
|
|
for( int i = bi; i < ei; i++, p++ )
|
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat r = data.row(i);
|
2012-06-09 23:00:04 +08:00
|
|
|
r = r * (*cit) + *mit;
|
2011-02-10 04:55:11 +08:00
|
|
|
if( labelType == CV_32FC1 )
|
|
|
|
labels.at<float>(p, 0) = (float)l;
|
2012-03-29 15:01:57 +08:00
|
|
|
else if( labelType == CV_32SC1 )
|
2011-02-10 04:55:11 +08:00
|
|
|
labels.at<int>(p, 0) = l;
|
2012-03-29 15:01:57 +08:00
|
|
|
else
|
2012-06-20 20:27:02 +08:00
|
|
|
{
|
2012-03-29 15:01:57 +08:00
|
|
|
CV_DbgAssert(0);
|
2012-06-20 20:27:02 +08:00
|
|
|
}
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
static
|
2011-02-10 04:55:11 +08:00
|
|
|
int maxIdx( const vector<int>& count )
|
|
|
|
{
|
|
|
|
int idx = -1;
|
|
|
|
int maxVal = -1;
|
|
|
|
vector<int>::const_iterator it = count.begin();
|
|
|
|
for( int i = 0; it != count.end(); ++it, i++ )
|
|
|
|
{
|
|
|
|
if( *it > maxVal)
|
|
|
|
{
|
|
|
|
maxVal = *it;
|
|
|
|
idx = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert( idx >= 0);
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
static
|
2012-04-30 22:33:52 +08:00
|
|
|
bool getLabelsMap( const Mat& labels, const vector<int>& sizes, vector<int>& labelsMap, bool checkClusterUniq=true )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
size_t total = 0, nclusters = sizes.size();
|
|
|
|
for(size_t i = 0; i < sizes.size(); i++)
|
|
|
|
total += sizes[i];
|
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
assert( !labels.empty() );
|
2012-04-14 05:50:59 +08:00
|
|
|
assert( labels.total() == total && (labels.cols == 1 || labels.rows == 1));
|
2011-02-10 04:55:11 +08:00
|
|
|
assert( labels.type() == CV_32SC1 || labels.type() == CV_32FC1 );
|
|
|
|
|
|
|
|
bool isFlt = labels.type() == CV_32FC1;
|
2012-04-14 05:50:59 +08:00
|
|
|
|
|
|
|
labelsMap.resize(nclusters);
|
|
|
|
|
|
|
|
vector<bool> buzy(nclusters, false);
|
|
|
|
int startIndex = 0;
|
|
|
|
for( size_t clusterIndex = 0; clusterIndex < sizes.size(); clusterIndex++ )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
vector<int> count( nclusters, 0 );
|
|
|
|
for( int i = startIndex; i < startIndex + sizes[clusterIndex]; i++)
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
int lbl = isFlt ? (int)labels.at<float>(i) : labels.at<int>(i);
|
|
|
|
CV_Assert(lbl < (int)nclusters);
|
|
|
|
count[lbl]++;
|
|
|
|
CV_Assert(count[lbl] < (int)total);
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
2012-04-14 05:50:59 +08:00
|
|
|
startIndex += sizes[clusterIndex];
|
|
|
|
|
|
|
|
int cls = maxIdx( count );
|
2012-04-30 22:33:52 +08:00
|
|
|
CV_Assert( !checkClusterUniq || !buzy[cls] );
|
2012-04-14 05:50:59 +08:00
|
|
|
|
|
|
|
labelsMap[clusterIndex] = cls;
|
|
|
|
|
|
|
|
buzy[cls] = true;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
2012-04-30 22:33:52 +08:00
|
|
|
|
|
|
|
if(checkClusterUniq)
|
|
|
|
{
|
|
|
|
for(size_t i = 0; i < buzy.size(); i++)
|
|
|
|
if(!buzy[i])
|
|
|
|
return false;
|
|
|
|
}
|
2012-04-14 05:50:59 +08:00
|
|
|
|
|
|
|
return true;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
static
|
2012-04-30 22:33:52 +08:00
|
|
|
bool calcErr( const Mat& labels, const Mat& origLabels, const vector<int>& sizes, float& err, bool labelsEquivalent = true, bool checkClusterUniq=true )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
err = 0;
|
|
|
|
CV_Assert( !labels.empty() && !origLabels.empty() );
|
|
|
|
CV_Assert( labels.rows == 1 || labels.cols == 1 );
|
|
|
|
CV_Assert( origLabels.rows == 1 || origLabels.cols == 1 );
|
|
|
|
CV_Assert( labels.total() == origLabels.total() );
|
|
|
|
CV_Assert( labels.type() == CV_32SC1 || labels.type() == CV_32FC1 );
|
|
|
|
CV_Assert( origLabels.type() == labels.type() );
|
2011-02-10 04:55:11 +08:00
|
|
|
|
|
|
|
vector<int> labelsMap;
|
|
|
|
bool isFlt = labels.type() == CV_32FC1;
|
|
|
|
if( !labelsEquivalent )
|
|
|
|
{
|
2012-04-30 22:33:52 +08:00
|
|
|
if( !getLabelsMap( labels, sizes, labelsMap, checkClusterUniq ) )
|
2012-04-14 05:50:59 +08:00
|
|
|
return false;
|
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
for( int i = 0; i < labels.rows; i++ )
|
|
|
|
if( isFlt )
|
2012-04-14 05:50:59 +08:00
|
|
|
err += labels.at<float>(i) != labelsMap[(int)origLabels.at<float>(i)] ? 1.f : 0.f;
|
2011-02-10 04:55:11 +08:00
|
|
|
else
|
2012-04-14 05:50:59 +08:00
|
|
|
err += labels.at<int>(i) != labelsMap[origLabels.at<int>(i)] ? 1.f : 0.f;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( int i = 0; i < labels.rows; i++ )
|
|
|
|
if( isFlt )
|
2012-04-14 05:50:59 +08:00
|
|
|
err += labels.at<float>(i) != origLabels.at<float>(i) ? 1.f : 0.f;
|
2011-02-10 04:55:11 +08:00
|
|
|
else
|
2012-04-14 05:50:59 +08:00
|
|
|
err += labels.at<int>(i) != origLabels.at<int>(i) ? 1.f : 0.f;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
2012-04-14 05:50:59 +08:00
|
|
|
err /= (float)labels.rows;
|
|
|
|
return true;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------
|
|
|
|
class CV_KMeansTest : public cvtest::BaseTest {
|
|
|
|
public:
|
|
|
|
CV_KMeansTest() {}
|
|
|
|
protected:
|
|
|
|
virtual void run( int start_from );
|
|
|
|
};
|
|
|
|
|
|
|
|
void CV_KMeansTest::run( int /*start_from*/ )
|
|
|
|
{
|
|
|
|
const int iters = 100;
|
|
|
|
int sizesArr[] = { 5000, 7000, 8000 };
|
|
|
|
int pointsCount = sizesArr[0]+ sizesArr[1] + sizesArr[2];
|
2012-06-09 23:00:04 +08:00
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
Mat data( pointsCount, 2, CV_32FC1 ), labels;
|
|
|
|
vector<int> sizes( sizesArr, sizesArr + sizeof(sizesArr) / sizeof(sizesArr[0]) );
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat means;
|
|
|
|
vector<Mat> covs;
|
2011-02-10 04:55:11 +08:00
|
|
|
defaultDistribs( means, covs );
|
2012-04-14 05:50:59 +08:00
|
|
|
generateData( data, labels, sizes, means, covs, CV_32FC1, CV_32SC1 );
|
2012-06-09 23:00:04 +08:00
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
int code = cvtest::TS::OK;
|
2012-03-29 15:01:57 +08:00
|
|
|
float err;
|
2011-02-10 04:55:11 +08:00
|
|
|
Mat bestLabels;
|
|
|
|
// 1. flag==KMEANS_PP_CENTERS
|
2011-06-08 14:55:04 +08:00
|
|
|
kmeans( data, 3, bestLabels, TermCriteria( TermCriteria::COUNT, iters, 0.0), 0, KMEANS_PP_CENTERS, noArray() );
|
2012-04-14 05:50:59 +08:00
|
|
|
if( !calcErr( bestLabels, labels, sizes, err , false ) )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Bad output labels if flag==KMEANS_PP_CENTERS.\n" );
|
|
|
|
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
|
|
|
}
|
|
|
|
else if( err > 0.01f )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-03-29 15:01:57 +08:00
|
|
|
ts->printf( cvtest::TS::LOG, "Bad accuracy (%f) if flag==KMEANS_PP_CENTERS.\n", err );
|
2011-02-10 04:55:11 +08:00
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2. flag==KMEANS_RANDOM_CENTERS
|
2011-06-08 14:55:04 +08:00
|
|
|
kmeans( data, 3, bestLabels, TermCriteria( TermCriteria::COUNT, iters, 0.0), 0, KMEANS_RANDOM_CENTERS, noArray() );
|
2012-04-14 05:50:59 +08:00
|
|
|
if( !calcErr( bestLabels, labels, sizes, err, false ) )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
ts->printf( cvtest::TS::LOG, "Bad output labels if flag==KMEANS_RANDOM_CENTERS.\n" );
|
|
|
|
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
|
|
|
}
|
|
|
|
else if( err > 0.01f )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Bad accuracy (%f) if flag==KMEANS_RANDOM_CENTERS.\n", err );
|
2011-02-10 04:55:11 +08:00
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3. flag==KMEANS_USE_INITIAL_LABELS
|
|
|
|
labels.copyTo( bestLabels );
|
|
|
|
RNG rng;
|
|
|
|
for( int i = 0; i < 0.5f * pointsCount; i++ )
|
|
|
|
bestLabels.at<int>( rng.next() % pointsCount, 0 ) = rng.next() % 3;
|
2011-06-08 14:55:04 +08:00
|
|
|
kmeans( data, 3, bestLabels, TermCriteria( TermCriteria::COUNT, iters, 0.0), 0, KMEANS_USE_INITIAL_LABELS, noArray() );
|
2012-04-14 05:50:59 +08:00
|
|
|
if( !calcErr( bestLabels, labels, sizes, err, false ) )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
ts->printf( cvtest::TS::LOG, "Bad output labels if flag==KMEANS_USE_INITIAL_LABELS.\n" );
|
|
|
|
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
|
|
|
}
|
|
|
|
else if( err > 0.01f )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Bad accuracy (%f) if flag==KMEANS_USE_INITIAL_LABELS.\n", err );
|
2011-02-10 04:55:11 +08:00
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ts->set_failed_test_info( code );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------
|
|
|
|
class CV_KNearestTest : public cvtest::BaseTest {
|
|
|
|
public:
|
|
|
|
CV_KNearestTest() {}
|
|
|
|
protected:
|
|
|
|
virtual void run( int start_from );
|
|
|
|
};
|
|
|
|
|
|
|
|
void CV_KNearestTest::run( int /*start_from*/ )
|
|
|
|
{
|
|
|
|
int sizesArr[] = { 500, 700, 800 };
|
|
|
|
int pointsCount = sizesArr[0]+ sizesArr[1] + sizesArr[2];
|
|
|
|
|
|
|
|
// train data
|
|
|
|
Mat trainData( pointsCount, 2, CV_32FC1 ), trainLabels;
|
|
|
|
vector<int> sizes( sizesArr, sizesArr + sizeof(sizesArr) / sizeof(sizesArr[0]) );
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat means;
|
|
|
|
vector<Mat> covs;
|
2011-02-10 04:55:11 +08:00
|
|
|
defaultDistribs( means, covs );
|
2012-04-14 05:50:59 +08:00
|
|
|
generateData( trainData, trainLabels, sizes, means, covs, CV_32FC1, CV_32FC1 );
|
2011-02-10 04:55:11 +08:00
|
|
|
|
|
|
|
// test data
|
|
|
|
Mat testData( pointsCount, 2, CV_32FC1 ), testLabels, bestLabels;
|
2012-04-14 05:50:59 +08:00
|
|
|
generateData( testData, testLabels, sizes, means, covs, CV_32FC1, CV_32FC1 );
|
2011-02-10 04:55:11 +08:00
|
|
|
|
|
|
|
int code = cvtest::TS::OK;
|
2014-08-23 22:41:32 +08:00
|
|
|
|
|
|
|
// KNearest default implementation
|
|
|
|
Ptr<KNearest> knearest = KNearest::create();
|
|
|
|
knearest->train(trainData, ml::ROW_SAMPLE, trainLabels);
|
|
|
|
knearest->findNearest(testData, 4, bestLabels);
|
2012-04-14 05:50:59 +08:00
|
|
|
float err;
|
|
|
|
if( !calcErr( bestLabels, testLabels, sizes, err, true ) )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Bad output labels.\n" );
|
|
|
|
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
|
|
|
}
|
|
|
|
else if( err > 0.01f )
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2012-03-29 15:01:57 +08:00
|
|
|
ts->printf( cvtest::TS::LOG, "Bad accuracy (%f) on test data.\n", err );
|
2011-02-10 04:55:11 +08:00
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
2014-08-23 22:41:32 +08:00
|
|
|
|
|
|
|
// KNearest KDTree implementation
|
2015-02-11 18:24:14 +08:00
|
|
|
Ptr<KNearest> knearestKdt = KNearest::create();
|
|
|
|
knearestKdt->setAlgorithmType(KNearest::KDTREE);
|
2014-08-23 22:41:32 +08:00
|
|
|
knearestKdt->train(trainData, ml::ROW_SAMPLE, trainLabels);
|
|
|
|
knearestKdt->findNearest(testData, 4, bestLabels);
|
|
|
|
if( !calcErr( bestLabels, testLabels, sizes, err, true ) )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Bad output labels.\n" );
|
|
|
|
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
|
|
|
}
|
2014-09-01 01:39:47 +08:00
|
|
|
else if( err > 0.01f )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Bad accuracy (%f) on test data.\n", err );
|
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
2014-08-23 22:41:32 +08:00
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
ts->set_failed_test_info( code );
|
|
|
|
}
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
class EM_Params
|
|
|
|
{
|
|
|
|
public:
|
2012-06-09 23:00:04 +08:00
|
|
|
EM_Params(int _nclusters=10, int _covMatType=EM::COV_MAT_DIAGONAL, int _startStep=EM::START_AUTO_STEP,
|
|
|
|
const cv::TermCriteria& _termCrit=cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS, 100, FLT_EPSILON),
|
|
|
|
const cv::Mat* _probs=0, const cv::Mat* _weights=0,
|
|
|
|
const cv::Mat* _means=0, const std::vector<cv::Mat>* _covs=0)
|
|
|
|
: nclusters(_nclusters), covMatType(_covMatType), startStep(_startStep),
|
|
|
|
probs(_probs), weights(_weights), means(_means), covs(_covs), termCrit(_termCrit)
|
2012-04-14 05:50:59 +08:00
|
|
|
{}
|
2012-06-09 23:00:04 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
int nclusters;
|
|
|
|
int covMatType;
|
|
|
|
int startStep;
|
2012-06-09 23:00:04 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
// all 4 following matrices should have type CV_32FC1
|
|
|
|
const cv::Mat* probs;
|
|
|
|
const cv::Mat* weights;
|
|
|
|
const cv::Mat* means;
|
|
|
|
const std::vector<cv::Mat>* covs;
|
2012-06-09 23:00:04 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
cv::TermCriteria termCrit;
|
|
|
|
};
|
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
//--------------------------------------------------------------------------------------------
|
2012-04-14 05:50:59 +08:00
|
|
|
class CV_EMTest : public cvtest::BaseTest
|
|
|
|
{
|
2011-02-10 04:55:11 +08:00
|
|
|
public:
|
|
|
|
CV_EMTest() {}
|
|
|
|
protected:
|
|
|
|
virtual void run( int start_from );
|
2012-04-14 05:50:59 +08:00
|
|
|
int runCase( int caseIndex, const EM_Params& params,
|
|
|
|
const cv::Mat& trainData, const cv::Mat& trainLabels,
|
|
|
|
const cv::Mat& testData, const cv::Mat& testLabels,
|
|
|
|
const vector<int>& sizes);
|
2011-02-10 04:55:11 +08:00
|
|
|
};
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
int CV_EMTest::runCase( int caseIndex, const EM_Params& params,
|
|
|
|
const cv::Mat& trainData, const cv::Mat& trainLabels,
|
|
|
|
const cv::Mat& testData, const cv::Mat& testLabels,
|
|
|
|
const vector<int>& sizes )
|
|
|
|
{
|
|
|
|
int code = cvtest::TS::OK;
|
|
|
|
|
|
|
|
cv::Mat labels;
|
|
|
|
float err;
|
|
|
|
|
2015-02-11 18:24:14 +08:00
|
|
|
Ptr<EM> em = EM::create();
|
|
|
|
em->setClustersNumber(params.nclusters);
|
|
|
|
em->setCovarianceMatrixType(params.covMatType);
|
|
|
|
em->setTermCriteria(params.termCrit);
|
2012-04-14 05:50:59 +08:00
|
|
|
if( params.startStep == EM::START_AUTO_STEP )
|
2015-02-11 18:24:14 +08:00
|
|
|
em->trainEM( trainData, noArray(), labels, noArray() );
|
2012-04-14 05:50:59 +08:00
|
|
|
else if( params.startStep == EM::START_E_STEP )
|
2015-02-11 18:24:14 +08:00
|
|
|
em->trainE( trainData, *params.means, *params.covs,
|
|
|
|
*params.weights, noArray(), labels, noArray() );
|
2012-04-14 05:50:59 +08:00
|
|
|
else if( params.startStep == EM::START_M_STEP )
|
2015-02-11 18:24:14 +08:00
|
|
|
em->trainM( trainData, *params.probs,
|
|
|
|
noArray(), labels, noArray() );
|
2012-04-14 05:50:59 +08:00
|
|
|
|
|
|
|
// check train error
|
2012-04-30 22:33:52 +08:00
|
|
|
if( !calcErr( labels, trainLabels, sizes, err , false, false ) )
|
2012-04-14 05:50:59 +08:00
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Case index %i : Bad output labels.\n", caseIndex );
|
|
|
|
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
|
|
|
}
|
|
|
|
else if( err > 0.008f )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Case index %i : Bad accuracy (%f) on train data.\n", caseIndex, err );
|
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check test error
|
|
|
|
labels.create( testData.rows, 1, CV_32SC1 );
|
|
|
|
for( int i = 0; i < testData.rows; i++ )
|
|
|
|
{
|
|
|
|
Mat sample = testData.row(i);
|
|
|
|
Mat probs;
|
2014-07-30 03:54:23 +08:00
|
|
|
labels.at<int>(i) = static_cast<int>(em->predict2( sample, probs )[1]);
|
2012-04-14 05:50:59 +08:00
|
|
|
}
|
2012-04-30 22:33:52 +08:00
|
|
|
if( !calcErr( labels, testLabels, sizes, err, false, false ) )
|
2012-04-14 05:50:59 +08:00
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Case index %i : Bad output labels.\n", caseIndex );
|
|
|
|
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
|
|
|
}
|
|
|
|
else if( err > 0.008f )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Case index %i : Bad accuracy (%f) on test data.\n", caseIndex, err );
|
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return code;
|
|
|
|
}
|
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
void CV_EMTest::run( int /*start_from*/ )
|
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
int sizesArr[] = { 500, 700, 800 };
|
2011-02-10 04:55:11 +08:00
|
|
|
int pointsCount = sizesArr[0]+ sizesArr[1] + sizesArr[2];
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
// Points distribution
|
|
|
|
Mat means;
|
|
|
|
vector<Mat> covs;
|
|
|
|
defaultDistribs( means, covs, CV_64FC1 );
|
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
// train data
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat trainData( pointsCount, 2, CV_64FC1 ), trainLabels;
|
2011-02-10 04:55:11 +08:00
|
|
|
vector<int> sizes( sizesArr, sizesArr + sizeof(sizesArr) / sizeof(sizesArr[0]) );
|
2012-04-14 05:50:59 +08:00
|
|
|
generateData( trainData, trainLabels, sizes, means, covs, CV_64FC1, CV_32SC1 );
|
2011-02-10 04:55:11 +08:00
|
|
|
|
|
|
|
// test data
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat testData( pointsCount, 2, CV_64FC1 ), testLabels;
|
|
|
|
generateData( testData, testLabels, sizes, means, covs, CV_64FC1, CV_32SC1 );
|
2011-02-10 04:55:11 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
EM_Params params;
|
2011-02-10 04:55:11 +08:00
|
|
|
params.nclusters = 3;
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat probs(trainData.rows, params.nclusters, CV_64FC1, cv::Scalar(1));
|
|
|
|
params.probs = &probs;
|
|
|
|
Mat weights(1, params.nclusters, CV_64FC1, cv::Scalar(1));
|
|
|
|
params.weights = &weights;
|
|
|
|
params.means = &means;
|
|
|
|
params.covs = &covs;
|
2011-02-10 04:55:11 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
int code = cvtest::TS::OK;
|
|
|
|
int caseIndex = 0;
|
2011-02-10 04:55:11 +08:00
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_AUTO_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_GENERIC;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_AUTO_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_DIAGONAL;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_AUTO_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_SPHERICAL;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_M_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_GENERIC;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_M_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_DIAGONAL;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_M_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_SPHERICAL;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_E_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_GENERIC;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_E_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_DIAGONAL;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
|
|
|
}
|
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
params.startStep = EM::START_E_STEP;
|
|
|
|
params.covMatType = EM::COV_MAT_SPHERICAL;
|
2012-04-14 05:50:59 +08:00
|
|
|
int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
|
|
|
|
code = currCode == cvtest::TS::OK ? code : currCode;
|
2011-02-10 04:55:11 +08:00
|
|
|
}
|
2012-06-09 23:00:04 +08:00
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
ts->set_failed_test_info( code );
|
|
|
|
}
|
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
class CV_EMTest_SaveLoad : public cvtest::BaseTest {
|
2012-03-29 16:55:43 +08:00
|
|
|
public:
|
2012-04-14 05:50:59 +08:00
|
|
|
CV_EMTest_SaveLoad() {}
|
2012-03-29 16:55:43 +08:00
|
|
|
protected:
|
|
|
|
virtual void run( int /*start_from*/ )
|
|
|
|
{
|
|
|
|
int code = cvtest::TS::OK;
|
2012-04-14 05:50:59 +08:00
|
|
|
const int nclusters = 2;
|
2012-03-29 16:55:43 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat samples = Mat(3,1,CV_64FC1);
|
|
|
|
samples.at<double>(0,0) = 1;
|
|
|
|
samples.at<double>(1,0) = 2;
|
|
|
|
samples.at<double>(2,0) = 3;
|
2012-03-29 16:55:43 +08:00
|
|
|
|
|
|
|
Mat labels;
|
|
|
|
|
2015-02-11 18:24:14 +08:00
|
|
|
Ptr<EM> em = EM::create();
|
|
|
|
em->setClustersNumber(nclusters);
|
|
|
|
em->trainEM(samples, noArray(), labels, noArray());
|
2012-03-29 16:55:43 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
Mat firstResult(samples.rows, 1, CV_32SC1);
|
2012-03-29 16:55:43 +08:00
|
|
|
for( int i = 0; i < samples.rows; i++)
|
2014-07-30 03:54:23 +08:00
|
|
|
firstResult.at<int>(i) = static_cast<int>(em->predict2(samples.row(i), noArray())[1]);
|
2012-03-29 16:55:43 +08:00
|
|
|
|
|
|
|
// Write out
|
2012-06-25 19:24:06 +08:00
|
|
|
string filename = cv::tempfile(".xml");
|
2012-03-29 16:55:43 +08:00
|
|
|
{
|
|
|
|
FileStorage fs = FileStorage(filename, FileStorage::WRITE);
|
|
|
|
try
|
|
|
|
{
|
2012-04-14 05:50:59 +08:00
|
|
|
fs << "em" << "{";
|
2014-07-30 03:54:23 +08:00
|
|
|
em->write(fs);
|
2012-04-14 05:50:59 +08:00
|
|
|
fs << "}";
|
2012-03-29 16:55:43 +08:00
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Crash in write method.\n" );
|
|
|
|
ts->set_failed_test_info( cvtest::TS::FAIL_EXCEPTION );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 03:54:23 +08:00
|
|
|
em.release();
|
2012-03-29 16:55:43 +08:00
|
|
|
|
|
|
|
// Read in
|
2014-07-30 03:54:23 +08:00
|
|
|
try
|
2012-03-29 16:55:43 +08:00
|
|
|
{
|
2014-07-30 03:54:23 +08:00
|
|
|
em = StatModel::load<EM>(filename);
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Crash in read method.\n" );
|
|
|
|
ts->set_failed_test_info( cvtest::TS::FAIL_EXCEPTION );
|
2012-03-29 16:55:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remove( filename.c_str() );
|
|
|
|
|
|
|
|
int errCaseCount = 0;
|
|
|
|
for( int i = 0; i < samples.rows; i++)
|
2014-07-30 03:54:23 +08:00
|
|
|
errCaseCount = std::abs(em->predict2(samples.row(i), noArray())[1] - firstResult.at<int>(i)) < FLT_EPSILON ? 0 : 1;
|
2012-03-29 16:55:43 +08:00
|
|
|
|
|
|
|
if( errCaseCount > 0 )
|
|
|
|
{
|
|
|
|
ts->printf( cvtest::TS::LOG, "Different prediction results before writeing and after reading (errCaseCount=%d).\n", errCaseCount );
|
|
|
|
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ts->set_failed_test_info( code );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-04-30 22:33:52 +08:00
|
|
|
class CV_EMTest_Classification : public cvtest::BaseTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CV_EMTest_Classification() {}
|
|
|
|
protected:
|
|
|
|
virtual void run(int)
|
|
|
|
{
|
|
|
|
// This test classifies spam by the following way:
|
|
|
|
// 1. estimates distributions of "spam" / "not spam"
|
|
|
|
// 2. predict classID using Bayes classifier for estimated distributions.
|
|
|
|
|
|
|
|
string dataFilename = string(ts->get_data_path()) + "spambase.data";
|
2014-07-30 03:54:23 +08:00
|
|
|
Ptr<TrainData> data = TrainData::loadFromCSV(dataFilename, 0);
|
2012-04-30 22:33:52 +08:00
|
|
|
|
2014-07-30 03:54:23 +08:00
|
|
|
if( data.empty() )
|
2012-04-30 22:33:52 +08:00
|
|
|
{
|
|
|
|
ts->printf(cvtest::TS::LOG, "File with spambase dataset cann't be read.\n");
|
|
|
|
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
|
|
|
}
|
|
|
|
|
2014-07-30 03:54:23 +08:00
|
|
|
Mat samples = data->getSamples();
|
|
|
|
CV_Assert(samples.cols == 57);
|
|
|
|
Mat responses = data->getResponses();
|
2012-04-30 22:33:52 +08:00
|
|
|
|
|
|
|
vector<int> trainSamplesMask(samples.rows, 0);
|
|
|
|
int trainSamplesCount = (int)(0.5f * samples.rows);
|
|
|
|
for(int i = 0; i < trainSamplesCount; i++)
|
|
|
|
trainSamplesMask[i] = 1;
|
|
|
|
RNG rng(0);
|
|
|
|
for(size_t i = 0; i < trainSamplesMask.size(); i++)
|
|
|
|
{
|
|
|
|
int i1 = rng(static_cast<unsigned>(trainSamplesMask.size()));
|
|
|
|
int i2 = rng(static_cast<unsigned>(trainSamplesMask.size()));
|
|
|
|
std::swap(trainSamplesMask[i1], trainSamplesMask[i2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Mat samples0, samples1;
|
|
|
|
for(int i = 0; i < samples.rows; i++)
|
|
|
|
{
|
|
|
|
if(trainSamplesMask[i])
|
|
|
|
{
|
|
|
|
Mat sample = samples.row(i);
|
|
|
|
int resp = (int)responses.at<float>(i);
|
|
|
|
if(resp == 0)
|
|
|
|
samples0.push_back(sample);
|
|
|
|
else
|
|
|
|
samples1.push_back(sample);
|
|
|
|
}
|
|
|
|
}
|
2015-02-11 18:24:14 +08:00
|
|
|
Ptr<EM> model0 = EM::create();
|
|
|
|
model0->setClustersNumber(3);
|
|
|
|
model0->trainEM(samples0, noArray(), noArray(), noArray());
|
|
|
|
|
|
|
|
Ptr<EM> model1 = EM::create();
|
|
|
|
model1->setClustersNumber(3);
|
|
|
|
model1->trainEM(samples1, noArray(), noArray(), noArray());
|
2012-04-30 22:33:52 +08:00
|
|
|
|
|
|
|
Mat trainConfusionMat(2, 2, CV_32SC1, Scalar(0)),
|
|
|
|
testConfusionMat(2, 2, CV_32SC1, Scalar(0));
|
|
|
|
const double lambda = 1.;
|
|
|
|
for(int i = 0; i < samples.rows; i++)
|
|
|
|
{
|
|
|
|
Mat sample = samples.row(i);
|
2014-07-30 03:54:23 +08:00
|
|
|
double sampleLogLikelihoods0 = model0->predict2(sample, noArray())[0];
|
|
|
|
double sampleLogLikelihoods1 = model1->predict2(sample, noArray())[0];
|
2012-04-30 22:33:52 +08:00
|
|
|
|
|
|
|
int classID = sampleLogLikelihoods0 >= lambda * sampleLogLikelihoods1 ? 0 : 1;
|
|
|
|
|
|
|
|
if(trainSamplesMask[i])
|
|
|
|
trainConfusionMat.at<int>((int)responses.at<float>(i), classID)++;
|
|
|
|
else
|
|
|
|
testConfusionMat.at<int>((int)responses.at<float>(i), classID)++;
|
|
|
|
}
|
|
|
|
// std::cout << trainConfusionMat << std::endl;
|
|
|
|
// std::cout << testConfusionMat << std::endl;
|
|
|
|
|
|
|
|
double trainError = (double)(trainConfusionMat.at<int>(1,0) + trainConfusionMat.at<int>(0,1)) / trainSamplesCount;
|
|
|
|
double testError = (double)(testConfusionMat.at<int>(1,0) + testConfusionMat.at<int>(0,1)) / (samples.rows - trainSamplesCount);
|
2012-07-11 21:52:19 +08:00
|
|
|
const double maxTrainError = 0.23;
|
|
|
|
const double maxTestError = 0.26;
|
2012-04-30 22:33:52 +08:00
|
|
|
|
|
|
|
int code = cvtest::TS::OK;
|
|
|
|
if(trainError > maxTrainError)
|
|
|
|
{
|
|
|
|
ts->printf(cvtest::TS::LOG, "Too large train classification error (calc = %f, valid=%f).\n", trainError, maxTrainError);
|
|
|
|
code = cvtest::TS::FAIL_INVALID_TEST_DATA;
|
|
|
|
}
|
|
|
|
if(testError > maxTestError)
|
|
|
|
{
|
2012-07-11 21:52:19 +08:00
|
|
|
ts->printf(cvtest::TS::LOG, "Too large test classification error (calc = %f, valid=%f).\n", testError, maxTestError);
|
2012-04-30 22:33:52 +08:00
|
|
|
code = cvtest::TS::FAIL_INVALID_TEST_DATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
ts->set_failed_test_info(code);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-02-10 04:55:11 +08:00
|
|
|
TEST(ML_KMeans, accuracy) { CV_KMeansTest test; test.safe_run(); }
|
|
|
|
TEST(ML_KNearest, accuracy) { CV_KNearestTest test; test.safe_run(); }
|
2012-03-29 15:01:57 +08:00
|
|
|
TEST(ML_EM, accuracy) { CV_EMTest test; test.safe_run(); }
|
2012-04-14 05:50:59 +08:00
|
|
|
TEST(ML_EM, save_load) { CV_EMTest_SaveLoad test; test.safe_run(); }
|
2012-04-30 22:33:52 +08:00
|
|
|
TEST(ML_EM, classification) { CV_EMTest_Classification test; test.safe_run(); }
|