2011-10-07 21:55:26 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
using namespace perf;
|
2011-12-30 00:46:16 +08:00
|
|
|
using std::tr1::make_tuple;
|
|
|
|
using std::tr1::get;
|
2011-10-07 21:55:26 +08:00
|
|
|
|
|
|
|
typedef perf::TestBaseWithParam<size_t> VectorLength;
|
|
|
|
|
2012-10-10 16:28:17 +08:00
|
|
|
typedef std::tr1::tuple<int, int> MaxDim_MaxPoints_t;
|
|
|
|
typedef perf::TestBaseWithParam<MaxDim_MaxPoints_t> MaxDim_MaxPoints;
|
|
|
|
|
2011-10-07 21:55:26 +08:00
|
|
|
PERF_TEST_P(VectorLength, phase32f, testing::Values(128, 1000, 128*1024, 512*1024, 1024*1024))
|
|
|
|
{
|
2012-03-17 05:21:04 +08:00
|
|
|
size_t length = GetParam();
|
2011-10-07 21:55:26 +08:00
|
|
|
vector<float> X(length);
|
|
|
|
vector<float> Y(length);
|
|
|
|
vector<float> angle(length);
|
|
|
|
|
|
|
|
declare.in(X, Y, WARMUP_RNG).out(angle);
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE_N(200) cv::phase(X, Y, angle, true);
|
2011-10-07 21:55:26 +08:00
|
|
|
|
2011-12-28 00:37:24 +08:00
|
|
|
SANITY_CHECK(angle, 5e-5);
|
2011-10-07 21:55:26 +08:00
|
|
|
}
|
2012-10-10 16:28:17 +08:00
|
|
|
|
|
|
|
PERF_TEST_P( MaxDim_MaxPoints, kmeans,
|
|
|
|
testing::Combine( testing::Values( 16, 32, 64 ),
|
|
|
|
testing::Values( 300, 400, 500) ) )
|
|
|
|
{
|
|
|
|
RNG& rng = theRNG();
|
|
|
|
const int MAX_DIM = get<0>(GetParam());
|
|
|
|
const int MAX_POINTS = get<1>(GetParam());
|
|
|
|
const int attempts = 5;
|
|
|
|
|
|
|
|
Mat labels, centers;
|
|
|
|
int i, N = 0, N0 = 0, K = 0, dims = 0;
|
|
|
|
dims = rng.uniform(1, MAX_DIM+1);
|
|
|
|
N = rng.uniform(1, MAX_POINTS+1);
|
|
|
|
N0 = rng.uniform(1, MAX(N/10, 2));
|
|
|
|
K = rng.uniform(1, N+1);
|
|
|
|
|
|
|
|
Mat data0(N0, dims, CV_32F);
|
|
|
|
rng.fill(data0, RNG::UNIFORM, -1, 1);
|
|
|
|
|
|
|
|
Mat data(N, dims, CV_32F);
|
|
|
|
for( i = 0; i < N; i++ )
|
|
|
|
data0.row(rng.uniform(0, N0)).copyTo(data.row(i));
|
|
|
|
|
|
|
|
declare.in(data);
|
|
|
|
|
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
|
|
|
|
attempts, KMEANS_PP_CENTERS, centers);
|
|
|
|
}
|
|
|
|
|
|
|
|
Mat clusterPointsNumber = Mat::zeros(1, K, CV_32S);
|
|
|
|
|
|
|
|
for( i = 0; i < labels.rows; i++ )
|
|
|
|
{
|
|
|
|
int clusterIdx = labels.at<int>(i);
|
|
|
|
clusterPointsNumber.at<int>(clusterIdx)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Mat sortedClusterPointsNumber;
|
|
|
|
cv::sort(clusterPointsNumber, sortedClusterPointsNumber, cv::SORT_EVERY_ROW + cv::SORT_ASCENDING);
|
|
|
|
|
|
|
|
SANITY_CHECK(sortedClusterPointsNumber);
|
|
|
|
}
|