Merge remote-tracking branch 'origin/2.4'
Conflicts: doc/tutorials/features2d/feature_detection/feature_detection.rst modules/bioinspired/doc/retina/index.rst modules/core/include/opencv2/core/core.hpp modules/core/include/opencv2/core/mat.hpp modules/core/include/opencv2/core/operations.hpp modules/core/src/stat.cpp modules/features2d/include/opencv2/features2d/features2d.hpp modules/imgproc/src/filter.cpp modules/legacy/src/dpstereo.cpp modules/nonfree/src/surf.ocl.cpp modules/ocl/doc/image_processing.rst modules/ocl/doc/object_detection.rst modules/ocl/include/opencv2/ocl/ocl.hpp modules/ocl/include/opencv2/ocl/private/util.hpp modules/ocl/src/arithm.cpp modules/ocl/src/canny.cpp modules/ocl/src/filtering.cpp modules/ocl/src/imgproc.cpp modules/ocl/src/initialization.cpp modules/ocl/src/matrix_operations.cpp modules/ocl/src/pyrdown.cpp modules/ocl/src/pyrup.cpp modules/ocl/src/split_merge.cpp modules/ocl/test/test_objdetect.cpp modules/ocl/test/utility.hpp
This commit is contained in:
@@ -842,54 +842,6 @@ PERF_TEST_P(PowFixture, pow, OCL_TYPICAL_MAT_SIZES)
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
///////////// MagnitudeSqr////////////////////////
|
||||
|
||||
typedef TestBaseWithParam<Size> MagnitudeSqrFixture;
|
||||
|
||||
PERF_TEST_P(MagnitudeSqrFixture, MagnitudeSqr, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
const Size srcSize = GetParam();
|
||||
|
||||
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
|
||||
dst(srcSize, CV_32FC1);
|
||||
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
||||
|
||||
if (RUN_OCL_IMPL)
|
||||
{
|
||||
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst(srcSize, src1.type());
|
||||
|
||||
OCL_TEST_CYCLE() cv::ocl::magnitudeSqr(oclSrc1, oclSrc2, oclDst);
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
ASSERT_EQ(1, src1.channels());
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
for (int y = 0; y < srcSize.height; ++y)
|
||||
{
|
||||
const float * const src1Data = reinterpret_cast<float *>(src1.data + src1.step * y);
|
||||
const float * const src2Data = reinterpret_cast<float *>(src2.data + src2.step * y);
|
||||
float * const dstData = reinterpret_cast<float *>(dst.data + dst.step * y);
|
||||
for (int x = 0; x < srcSize.width; ++x)
|
||||
{
|
||||
float t0 = src1Data[x] * src1Data[x];
|
||||
float t1 = src2Data[x] * src2Data[x];
|
||||
dstData[x] = t0 + t1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
///////////// AddWeighted////////////////////////
|
||||
|
||||
typedef Size_MatType AddWeightedFixture;
|
||||
|
@@ -44,12 +44,14 @@
|
||||
//
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using namespace std;
|
||||
using namespace cv::ocl;
|
||||
using namespace cv;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
#if defined(HAVE_XINE) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
@@ -63,6 +65,7 @@ using std::tr1::get;
|
||||
#endif
|
||||
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
static void cvtFrameFmt(vector<Mat>& input, vector<Mat>& output)
|
||||
{
|
||||
for(int i = 0; i< (int)(input.size()); i++)
|
||||
@@ -70,6 +73,7 @@ static void cvtFrameFmt(vector<Mat>& input, vector<Mat>& output)
|
||||
cvtColor(input[i], output[i], COLOR_RGB2GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
//prepare data for CPU
|
||||
static void prepareData(VideoCapture& cap, int cn, vector<Mat>& frame_buffer)
|
||||
{
|
||||
@@ -88,15 +92,15 @@ static void prepareData(VideoCapture& cap, int cn, vector<Mat>& frame_buffer)
|
||||
else
|
||||
frame_buffer = frame_buffer_init;
|
||||
}
|
||||
|
||||
//copy CPU data to GPU
|
||||
static void prepareData(vector<Mat>& frame_buffer, vector<oclMat>& frame_buffer_ocl)
|
||||
{
|
||||
for(int i = 0; i < (int)frame_buffer.size(); i++)
|
||||
frame_buffer_ocl.push_back(cv::ocl::oclMat(frame_buffer[i]));
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////// MOG ////////////////////////
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
typedef tuple<string, int, double> VideoMOGParamType;
|
||||
typedef TestBaseWithParam<VideoMOGParamType> VideoMOGFixture;
|
||||
@@ -137,7 +141,8 @@ PERF_TEST_P(VideoMOGFixture, MOG,
|
||||
}
|
||||
}
|
||||
SANITY_CHECK(foreground);
|
||||
}else if(RUN_OCL_IMPL)
|
||||
}
|
||||
else if(RUN_OCL_IMPL)
|
||||
{
|
||||
prepareData(frame_buffer, frame_buffer_ocl);
|
||||
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
|
||||
@@ -152,13 +157,12 @@ PERF_TEST_P(VideoMOGFixture, MOG,
|
||||
}
|
||||
foreground_d.download(foreground);
|
||||
SANITY_CHECK(foreground);
|
||||
}else
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////// MOG2 ////////////////////////
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
typedef tuple<string, int> VideoMOG2ParamType;
|
||||
typedef TestBaseWithParam<VideoMOG2ParamType> VideoMOG2Fixture;
|
||||
@@ -196,7 +200,8 @@ PERF_TEST_P(VideoMOG2Fixture, MOG2,
|
||||
}
|
||||
}
|
||||
SANITY_CHECK(foreground);
|
||||
}else if(RUN_OCL_IMPL)
|
||||
}
|
||||
else if(RUN_OCL_IMPL)
|
||||
{
|
||||
prepareData(frame_buffer, frame_buffer_ocl);
|
||||
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
|
||||
@@ -211,13 +216,12 @@ PERF_TEST_P(VideoMOG2Fixture, MOG2,
|
||||
}
|
||||
foreground_d.download(foreground);
|
||||
SANITY_CHECK(foreground);
|
||||
}else
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////// MOG2_GetBackgroundImage //////////////////
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
typedef TestBaseWithParam<VideoMOG2ParamType> Video_MOG2GetBackgroundImage;
|
||||
|
||||
@@ -259,7 +263,8 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
|
||||
mog2->getBackgroundImage(background);
|
||||
}
|
||||
SANITY_CHECK(background);
|
||||
}else if(RUN_OCL_IMPL)
|
||||
}
|
||||
else if(RUN_OCL_IMPL)
|
||||
{
|
||||
prepareData(frame_buffer, frame_buffer_ocl);
|
||||
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
|
||||
@@ -276,7 +281,9 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
|
||||
}
|
||||
background_d.download(background);
|
||||
SANITY_CHECK(background);
|
||||
}else
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -333,13 +333,13 @@ PERF_TEST_P(BilateralFixture, Bilateral,
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), d = 7;
|
||||
double sigmacolor = 50.0, sigmaspace = 50.0;
|
||||
const double sigmacolor = 50.0, sigmaspace = 50.0;
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000 && type == CV_8UC3)
|
||||
declare.time(8);
|
||||
if (srcSize == OCL_SIZE_4000)
|
||||
declare.time(type == CV_8UC3 ? 8 : 4.5);
|
||||
|
||||
if (RUN_OCL_IMPL)
|
||||
{
|
||||
@@ -372,14 +372,16 @@ PERF_TEST_P(adaptiveBilateralFixture, adaptiveBilateral,
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
double sigmaspace = 10.0;
|
||||
Size ksize(9,9);
|
||||
const double sigmaspace = 10.0;
|
||||
Size ksize(9, 9);
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000)
|
||||
declare.time(15);
|
||||
declare.time(type == CV_8UC3 ? 46 : 28);
|
||||
else if (srcSize == OCL_SIZE_2000)
|
||||
declare.time(type == CV_8UC3 ? 11 : 7);
|
||||
|
||||
if (RUN_OCL_IMPL)
|
||||
{
|
||||
@@ -389,7 +391,7 @@ PERF_TEST_P(adaptiveBilateralFixture, adaptiveBilateral,
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst, 1.);
|
||||
SANITY_CHECK(dst, 1.0);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
|
@@ -49,6 +49,23 @@ using namespace perf;
|
||||
|
||||
///////////// HOG////////////////////////
|
||||
|
||||
struct RectLess :
|
||||
public std::binary_function<cv::Rect, cv::Rect, bool>
|
||||
{
|
||||
bool operator()(const cv::Rect& a,
|
||||
const cv::Rect& b) const
|
||||
{
|
||||
if (a.x != b.x)
|
||||
return a.x < b.x;
|
||||
else if (a.y != b.y)
|
||||
return a.y < b.y;
|
||||
else if (a.width != b.width)
|
||||
return a.width < b.width;
|
||||
else
|
||||
return a.height < b.height;
|
||||
}
|
||||
};
|
||||
|
||||
PERF_TEST(HOGFixture, HOG)
|
||||
{
|
||||
Mat src = imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE);
|
||||
@@ -64,6 +81,7 @@ PERF_TEST(HOGFixture, HOG)
|
||||
|
||||
TEST_CYCLE() hog.detectMultiScale(src, found_locations);
|
||||
|
||||
std::sort(found_locations.begin(), found_locations.end(), RectLess());
|
||||
SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
|
||||
}
|
||||
else if (RUN_OCL_IMPL)
|
||||
@@ -74,6 +92,7 @@ PERF_TEST(HOGFixture, HOG)
|
||||
|
||||
OCL_TEST_CYCLE() ocl_hog.detectMultiScale(oclSrc, found_locations);
|
||||
|
||||
std::sort(found_locations.begin(), found_locations.end(), RectLess());
|
||||
SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
|
||||
}
|
||||
else
|
||||
|
93
modules/ocl/perf/perf_kalman.cpp
Normal file
93
modules/ocl/perf/perf_kalman.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
//
|
||||
// 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 oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders 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 "perf_precomp.hpp"
|
||||
using namespace perf;
|
||||
using namespace std;
|
||||
using namespace cv::ocl;
|
||||
using namespace cv;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
///////////// Kalman Filter ////////////////////////
|
||||
|
||||
typedef tuple<int> KalmanFilterType;
|
||||
typedef TestBaseWithParam<KalmanFilterType> KalmanFilterFixture;
|
||||
|
||||
PERF_TEST_P(KalmanFilterFixture, KalmanFilter,
|
||||
::testing::Values(1000, 1500))
|
||||
{
|
||||
KalmanFilterType params = GetParam();
|
||||
const int dim = get<0>(params);
|
||||
|
||||
cv::Mat sample(dim, 1, CV_32FC1), dresult;
|
||||
randu(sample, -1, 1);
|
||||
|
||||
cv::Mat statePre_;
|
||||
|
||||
if(RUN_PLAIN_IMPL)
|
||||
{
|
||||
cv::KalmanFilter kalman;
|
||||
TEST_CYCLE()
|
||||
{
|
||||
kalman.init(dim, dim);
|
||||
kalman.correct(sample);
|
||||
kalman.predict();
|
||||
}
|
||||
statePre_ = kalman.statePre;
|
||||
}else if(RUN_OCL_IMPL)
|
||||
{
|
||||
cv::ocl::oclMat dsample(sample);
|
||||
cv::ocl::KalmanFilter kalman_ocl;
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
kalman_ocl.init(dim, dim);
|
||||
kalman_ocl.correct(dsample);
|
||||
kalman_ocl.predict();
|
||||
}
|
||||
kalman_ocl.statePre.download(statePre_);
|
||||
}else
|
||||
OCL_PERF_ELSE
|
||||
SANITY_CHECK(statePre_);
|
||||
}
|
@@ -155,3 +155,78 @@ PERF_TEST_P(setToFixture, setTo,
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
/////////////////// upload ///////////////////////////
|
||||
|
||||
typedef tuple<Size, int, int> uploadParams;
|
||||
typedef TestBaseWithParam<uploadParams> uploadFixture;
|
||||
|
||||
PERF_TEST_P(uploadFixture, DISABLED_upload,
|
||||
testing::Combine(
|
||||
OCL_TYPICAL_MAT_SIZES,
|
||||
testing::Range(CV_8U, CV_64F),
|
||||
testing::Range(1, 5)))
|
||||
{
|
||||
const uploadParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), cn = get<2>(params);
|
||||
const int type = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
Mat src(srcSize, type), dst;
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (RUN_OCL_IMPL)
|
||||
{
|
||||
ocl::oclMat oclDst;
|
||||
|
||||
for(; startTimer(), next(); ocl::finish(), stopTimer(), oclDst.release())
|
||||
oclDst.upload(src);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
for(; startTimer(), next(); ocl::finish(), stopTimer(), dst.release())
|
||||
dst = src.clone();
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
|
||||
int value = 0;
|
||||
SANITY_CHECK(value);
|
||||
}
|
||||
|
||||
/////////////////// download ///////////////////////////
|
||||
|
||||
typedef TestBaseWithParam<uploadParams> downloadFixture;
|
||||
|
||||
PERF_TEST_P(downloadFixture, DISABLED_download,
|
||||
testing::Combine(
|
||||
OCL_TYPICAL_MAT_SIZES,
|
||||
testing::Range(CV_8U, CV_64F),
|
||||
testing::Range(1, 5)))
|
||||
{
|
||||
const uploadParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), cn = get<2>(params);
|
||||
const int type = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
Mat src(srcSize, type), dst;
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (RUN_OCL_IMPL)
|
||||
{
|
||||
ocl::oclMat oclSrc(src);
|
||||
|
||||
for(; startTimer(), next(); ocl::finish(), stopTimer(), dst.release())
|
||||
oclSrc.download(dst);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
for(; startTimer(), next(); ocl::finish(), stopTimer(), dst.release())
|
||||
dst = src.clone();
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
|
||||
int value = 0;
|
||||
SANITY_CHECK(value);
|
||||
}
|
||||
|
109
modules/ocl/perf/perf_ml.cpp
Normal file
109
modules/ocl/perf/perf_ml.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
// Xiaopeng Fu, fuxiaopeng2222@163.com
|
||||
// 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 oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders 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 "perf_precomp.hpp"
|
||||
using namespace perf;
|
||||
using namespace std;
|
||||
using namespace cv::ocl;
|
||||
using namespace cv;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
////////////////////////////////// K-NEAREST NEIGHBOR ////////////////////////////////////
|
||||
static void genData(Mat& trainData, Size size, Mat& trainLabel = Mat().setTo(Scalar::all(0)), int nClasses = 0)
|
||||
{
|
||||
trainData.create(size, CV_32FC1);
|
||||
randu(trainData, 1.0, 100.0);
|
||||
|
||||
if(nClasses != 0)
|
||||
{
|
||||
trainLabel.create(size.height, 1, CV_8UC1);
|
||||
randu(trainLabel, 0, nClasses - 1);
|
||||
trainLabel.convertTo(trainLabel, CV_32FC1);
|
||||
}
|
||||
}
|
||||
|
||||
typedef tuple<int> KNNParamType;
|
||||
typedef TestBaseWithParam<KNNParamType> KNNFixture;
|
||||
|
||||
PERF_TEST_P(KNNFixture, KNN,
|
||||
testing::Values(1000, 2000, 4000))
|
||||
{
|
||||
KNNParamType params = GetParam();
|
||||
const int rows = get<0>(params);
|
||||
int columns = 100;
|
||||
int k = rows/250;
|
||||
|
||||
Mat trainData, trainLabels;
|
||||
Size size(columns, rows);
|
||||
genData(trainData, size, trainLabels, 3);
|
||||
|
||||
Mat testData;
|
||||
genData(testData, size);
|
||||
Mat best_label;
|
||||
|
||||
if(RUN_PLAIN_IMPL)
|
||||
{
|
||||
TEST_CYCLE()
|
||||
{
|
||||
CvKNearest knn_cpu;
|
||||
knn_cpu.train(trainData, trainLabels);
|
||||
knn_cpu.find_nearest(testData, k, &best_label);
|
||||
}
|
||||
}else if(RUN_OCL_IMPL)
|
||||
{
|
||||
cv::ocl::oclMat best_label_ocl;
|
||||
cv::ocl::oclMat testdata;
|
||||
testdata.upload(testData);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
cv::ocl::KNearestNeighbour knn_ocl;
|
||||
knn_ocl.train(trainData, trainLabels);
|
||||
knn_ocl.find_nearest(testdata, k, best_label_ocl);
|
||||
}
|
||||
best_label_ocl.download(best_label);
|
||||
}else
|
||||
OCL_PERF_ELSE
|
||||
SANITY_CHECK(best_label);
|
||||
}
|
Reference in New Issue
Block a user