mirror of https://github.com/opencv/opencv.git
Merge pull request #713 from bitwangyaoyao:2.4_perf
commit
2a1cf23fab
26 changed files with 3525 additions and 14039 deletions
@ -1,120 +0,0 @@ |
|||||||
/*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*/
|
|
||||||
|
|
||||||
#ifndef __OPENCV_TEST_INTERPOLATION_HPP__ |
|
||||||
#define __OPENCV_TEST_INTERPOLATION_HPP__ |
|
||||||
|
|
||||||
template <typename T> T readVal(const cv::Mat &src, int y, int x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) |
|
||||||
{ |
|
||||||
if (border_type == cv::BORDER_CONSTANT) |
|
||||||
return (y >= 0 && y < src.rows && x >= 0 && x < src.cols) ? src.at<T>(y, x * src.channels() + c) : cv::saturate_cast<T>(borderVal.val[c]); |
|
||||||
|
|
||||||
return src.at<T>(cv::borderInterpolate(y, src.rows, border_type), cv::borderInterpolate(x, src.cols, border_type) * src.channels() + c); |
|
||||||
} |
|
||||||
|
|
||||||
template <typename T> struct NearestInterpolator |
|
||||||
{ |
|
||||||
static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) |
|
||||||
{ |
|
||||||
return readVal<T>(src, cvFloor(y), cvFloor(x), c, border_type, borderVal); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
template <typename T> struct LinearInterpolator |
|
||||||
{ |
|
||||||
static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) |
|
||||||
{ |
|
||||||
x -= 0.5f; |
|
||||||
y -= 0.5f; |
|
||||||
|
|
||||||
int x1 = cvFloor(x); |
|
||||||
int y1 = cvFloor(y); |
|
||||||
int x2 = x1 + 1; |
|
||||||
int y2 = y1 + 1; |
|
||||||
|
|
||||||
float res = 0; |
|
||||||
|
|
||||||
res += readVal<T>(src, y1, x1, c, border_type, borderVal) * ((x2 - x) * (y2 - y)); |
|
||||||
res += readVal<T>(src, y1, x2, c, border_type, borderVal) * ((x - x1) * (y2 - y)); |
|
||||||
res += readVal<T>(src, y2, x1, c, border_type, borderVal) * ((x2 - x) * (y - y1)); |
|
||||||
res += readVal<T>(src, y2, x2, c, border_type, borderVal) * ((x - x1) * (y - y1)); |
|
||||||
|
|
||||||
return cv::saturate_cast<T>(res); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
template <typename T> struct CubicInterpolator |
|
||||||
{ |
|
||||||
static float getValue(float p[4], float x) |
|
||||||
{ |
|
||||||
return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0]))); |
|
||||||
} |
|
||||||
|
|
||||||
static float getValue(float p[4][4], float x, float y) |
|
||||||
{ |
|
||||||
float arr[4]; |
|
||||||
|
|
||||||
arr[0] = getValue(p[0], x); |
|
||||||
arr[1] = getValue(p[1], x); |
|
||||||
arr[2] = getValue(p[2], x); |
|
||||||
arr[3] = getValue(p[3], x); |
|
||||||
|
|
||||||
return getValue(arr, y); |
|
||||||
} |
|
||||||
|
|
||||||
static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) |
|
||||||
{ |
|
||||||
int ix = cvRound(x); |
|
||||||
int iy = cvRound(y); |
|
||||||
|
|
||||||
float vals[4][4] = |
|
||||||
{ |
|
||||||
{readVal<T>(src, iy - 2, ix - 2, c, border_type, borderVal), readVal<T>(src, iy - 2, ix - 1, c, border_type, borderVal), readVal<T>(src, iy - 2, ix, c, border_type, borderVal), readVal<T>(src, iy - 2, ix + 1, c, border_type, borderVal)}, |
|
||||||
{readVal<T>(src, iy - 1, ix - 2, c, border_type, borderVal), readVal<T>(src, iy - 1, ix - 1, c, border_type, borderVal), readVal<T>(src, iy - 1, ix, c, border_type, borderVal), readVal<T>(src, iy - 1, ix + 1, c, border_type, borderVal)}, |
|
||||||
{readVal<T>(src, iy , ix - 2, c, border_type, borderVal), readVal<T>(src, iy , ix - 1, c, border_type, borderVal), readVal<T>(src, iy , ix, c, border_type, borderVal), readVal<T>(src, iy , ix + 1, c, border_type, borderVal)}, |
|
||||||
{readVal<T>(src, iy + 1, ix - 2, c, border_type, borderVal), readVal<T>(src, iy + 1, ix - 1, c, border_type, borderVal), readVal<T>(src, iy + 1, ix, c, border_type, borderVal), readVal<T>(src, iy + 1, ix + 1, c, border_type, borderVal)}, |
|
||||||
}; |
|
||||||
|
|
||||||
return cv::saturate_cast<T>(getValue(vals, (x - ix + 2.0) / 4.0, (y - iy + 2.0) / 4.0)); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // __OPENCV_TEST_INTERPOLATION_HPP__
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,150 @@ |
|||||||
|
/*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
|
||||||
|
//
|
||||||
|
// 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 "precomp.hpp" |
||||||
|
|
||||||
|
//////////////////// BruteForceMatch /////////////////
|
||||||
|
TEST(BruteForceMatcher) |
||||||
|
{ |
||||||
|
Mat trainIdx_cpu; |
||||||
|
Mat distance_cpu; |
||||||
|
Mat allDist_cpu; |
||||||
|
Mat nMatches_cpu; |
||||||
|
|
||||||
|
for (int size = Min_Size; size <= Max_Size; size *= Multiple) |
||||||
|
{ |
||||||
|
// Init CPU matcher
|
||||||
|
int desc_len = 64; |
||||||
|
|
||||||
|
BFMatcher matcher(NORM_L2); |
||||||
|
|
||||||
|
Mat query; |
||||||
|
gen(query, size, desc_len, CV_32F, 0, 1); |
||||||
|
|
||||||
|
Mat train; |
||||||
|
gen(train, size, desc_len, CV_32F, 0, 1); |
||||||
|
// Output
|
||||||
|
vector< vector<DMatch> > matches(2); |
||||||
|
// Init GPU matcher
|
||||||
|
ocl::BruteForceMatcher_OCL_base d_matcher(ocl::BruteForceMatcher_OCL_base::L2Dist); |
||||||
|
|
||||||
|
ocl::oclMat d_query(query); |
||||||
|
ocl::oclMat d_train(train); |
||||||
|
|
||||||
|
ocl::oclMat d_trainIdx, d_distance, d_allDist, d_nMatches; |
||||||
|
|
||||||
|
SUBTEST << size << "; match"; |
||||||
|
|
||||||
|
matcher.match(query, train, matches[0]); |
||||||
|
|
||||||
|
CPU_ON; |
||||||
|
matcher.match(query, train, matches[0]); |
||||||
|
CPU_OFF; |
||||||
|
|
||||||
|
WARMUP_ON; |
||||||
|
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); |
||||||
|
WARMUP_OFF; |
||||||
|
|
||||||
|
GPU_ON; |
||||||
|
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); |
||||||
|
; |
||||||
|
GPU_OFF; |
||||||
|
|
||||||
|
GPU_FULL_ON; |
||||||
|
d_query.upload(query); |
||||||
|
d_train.upload(train); |
||||||
|
d_matcher.match(d_query, d_train, matches[0]); |
||||||
|
GPU_FULL_OFF; |
||||||
|
|
||||||
|
SUBTEST << size << "; knnMatch"; |
||||||
|
|
||||||
|
matcher.knnMatch(query, train, matches, 2); |
||||||
|
|
||||||
|
CPU_ON; |
||||||
|
matcher.knnMatch(query, train, matches, 2); |
||||||
|
CPU_OFF; |
||||||
|
|
||||||
|
WARMUP_ON; |
||||||
|
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, 2); |
||||||
|
WARMUP_OFF; |
||||||
|
|
||||||
|
GPU_ON; |
||||||
|
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, 2); |
||||||
|
; |
||||||
|
GPU_OFF; |
||||||
|
|
||||||
|
GPU_FULL_ON; |
||||||
|
d_query.upload(query); |
||||||
|
d_train.upload(train); |
||||||
|
d_matcher.knnMatch(d_query, d_train, matches, 2); |
||||||
|
GPU_FULL_OFF; |
||||||
|
|
||||||
|
SUBTEST << size << "; radiusMatch"; |
||||||
|
|
||||||
|
float max_distance = 2.0f; |
||||||
|
|
||||||
|
matcher.radiusMatch(query, train, matches, max_distance); |
||||||
|
|
||||||
|
CPU_ON; |
||||||
|
matcher.radiusMatch(query, train, matches, max_distance); |
||||||
|
CPU_OFF; |
||||||
|
|
||||||
|
d_trainIdx.release(); |
||||||
|
|
||||||
|
WARMUP_ON; |
||||||
|
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, max_distance); |
||||||
|
WARMUP_OFF; |
||||||
|
|
||||||
|
GPU_ON; |
||||||
|
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, max_distance); |
||||||
|
; |
||||||
|
GPU_OFF; |
||||||
|
|
||||||
|
GPU_FULL_ON; |
||||||
|
d_query.upload(query); |
||||||
|
d_train.upload(train); |
||||||
|
d_matcher.radiusMatch(d_query, d_train, matches, max_distance); |
||||||
|
GPU_FULL_OFF; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
/*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
|
||||||
|
//
|
||||||
|
// 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 "precomp.hpp" |
||||||
|
|
||||||
|
///////////// cvtColor////////////////////////
|
||||||
|
TEST(cvtColor) |
||||||
|
{ |
||||||
|
Mat src, dst; |
||||||
|
ocl::oclMat d_src, d_dst; |
||||||
|
|
||||||
|
int all_type[] = {CV_8UC4}; |
||||||
|
std::string type_name[] = {"CV_8UC4"}; |
||||||
|
|
||||||
|
for (int size = Min_Size; size <= Max_Size; size *= Multiple) |
||||||
|
{ |
||||||
|
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++) |
||||||
|
{ |
||||||
|
gen(src, size, size, all_type[j], 0, 256); |
||||||
|
SUBTEST << size << "x" << size << "; " << type_name[j] << " ; CV_RGBA2GRAY"; |
||||||
|
|
||||||
|
cvtColor(src, dst, CV_RGBA2GRAY, 4); |
||||||
|
|
||||||
|
CPU_ON; |
||||||
|
cvtColor(src, dst, CV_RGBA2GRAY, 4); |
||||||
|
CPU_OFF; |
||||||
|
|
||||||
|
d_src.upload(src); |
||||||
|
|
||||||
|
WARMUP_ON; |
||||||
|
ocl::cvtColor(d_src, d_dst, CV_RGBA2GRAY, 4); |
||||||
|
WARMUP_OFF; |
||||||
|
|
||||||
|
GPU_ON; |
||||||
|
ocl::cvtColor(d_src, d_dst, CV_RGBA2GRAY, 4); |
||||||
|
; |
||||||
|
GPU_OFF; |
||||||
|
|
||||||
|
GPU_FULL_ON; |
||||||
|
d_src.upload(src); |
||||||
|
ocl::cvtColor(d_src, d_dst, CV_RGBA2GRAY, 4); |
||||||
|
d_dst.download(dst); |
||||||
|
GPU_FULL_OFF; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,84 @@ |
|||||||
|
/*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
|
||||||
|
//
|
||||||
|
// 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 "precomp.hpp" |
||||||
|
|
||||||
|
///////////// norm////////////////////////
|
||||||
|
TEST(norm) |
||||||
|
{ |
||||||
|
Mat src, buf; |
||||||
|
ocl::oclMat d_src, d_buf; |
||||||
|
|
||||||
|
|
||||||
|
for (int size = Min_Size; size <= Max_Size; size *= Multiple) |
||||||
|
{ |
||||||
|
SUBTEST << size << 'x' << size << "; CV_8UC1; NORM_INF"; |
||||||
|
|
||||||
|
gen(src, size, size, CV_8UC1, Scalar::all(0), Scalar::all(1)); |
||||||
|
gen(buf, size, size, CV_8UC1, Scalar::all(0), Scalar::all(1)); |
||||||
|
|
||||||
|
norm(src, NORM_INF); |
||||||
|
|
||||||
|
CPU_ON; |
||||||
|
norm(src, NORM_INF); |
||||||
|
CPU_OFF; |
||||||
|
|
||||||
|
d_src.upload(src); |
||||||
|
d_buf.upload(buf); |
||||||
|
|
||||||
|
WARMUP_ON; |
||||||
|
ocl::norm(d_src, d_buf, NORM_INF); |
||||||
|
WARMUP_OFF; |
||||||
|
|
||||||
|
GPU_ON; |
||||||
|
ocl::norm(d_src, d_buf, NORM_INF); |
||||||
|
; |
||||||
|
GPU_OFF; |
||||||
|
|
||||||
|
GPU_FULL_ON; |
||||||
|
d_src.upload(src); |
||||||
|
ocl::norm(d_src, d_buf, NORM_INF); |
||||||
|
GPU_FULL_OFF; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,143 @@ |
|||||||
|
/*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
|
||||||
|
//
|
||||||
|
// 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 "precomp.hpp" |
||||||
|
|
||||||
|
///////////// PyrLKOpticalFlow ////////////////////////
|
||||||
|
TEST(PyrLKOpticalFlow) |
||||||
|
{ |
||||||
|
std::string images1[] = {"rubberwhale1.png", "aloeL.jpg"}; |
||||||
|
std::string images2[] = {"rubberwhale2.png", "aloeR.jpg"}; |
||||||
|
|
||||||
|
for (size_t i = 0; i < sizeof(images1) / sizeof(std::string); i++) |
||||||
|
{ |
||||||
|
Mat frame0 = imread(abspath(images1[i]), i == 0 ? IMREAD_COLOR : IMREAD_GRAYSCALE); |
||||||
|
|
||||||
|
if (frame0.empty()) |
||||||
|
{ |
||||||
|
std::string errstr = "can't open " + images1[i]; |
||||||
|
throw runtime_error(errstr); |
||||||
|
} |
||||||
|
|
||||||
|
Mat frame1 = imread(abspath(images2[i]), i == 0 ? IMREAD_COLOR : IMREAD_GRAYSCALE); |
||||||
|
|
||||||
|
if (frame1.empty()) |
||||||
|
{ |
||||||
|
std::string errstr = "can't open " + images2[i]; |
||||||
|
throw runtime_error(errstr); |
||||||
|
} |
||||||
|
|
||||||
|
Mat gray_frame; |
||||||
|
|
||||||
|
if (i == 0) |
||||||
|
{ |
||||||
|
cvtColor(frame0, gray_frame, COLOR_BGR2GRAY); |
||||||
|
} |
||||||
|
|
||||||
|
for (int points = Min_Size; points <= Max_Size; points *= Multiple) |
||||||
|
{ |
||||||
|
if (i == 0) |
||||||
|
SUBTEST << frame0.cols << "x" << frame0.rows << "; color; " << points << " points"; |
||||||
|
else |
||||||
|
SUBTEST << frame0.cols << "x" << frame0.rows << "; gray; " << points << " points"; |
||||||
|
Mat nextPts_cpu; |
||||||
|
Mat status_cpu; |
||||||
|
|
||||||
|
vector<Point2f> pts; |
||||||
|
goodFeaturesToTrack(i == 0 ? gray_frame : frame0, pts, points, 0.01, 0.0); |
||||||
|
|
||||||
|
vector<Point2f> nextPts; |
||||||
|
vector<unsigned char> status; |
||||||
|
|
||||||
|
vector<float> err; |
||||||
|
|
||||||
|
calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, err); |
||||||
|
|
||||||
|
CPU_ON; |
||||||
|
calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, err); |
||||||
|
CPU_OFF; |
||||||
|
|
||||||
|
ocl::PyrLKOpticalFlow d_pyrLK; |
||||||
|
|
||||||
|
ocl::oclMat d_frame0(frame0); |
||||||
|
ocl::oclMat d_frame1(frame1); |
||||||
|
|
||||||
|
ocl::oclMat d_pts; |
||||||
|
Mat pts_mat(1, (int)pts.size(), CV_32FC2, (void *)&pts[0]); |
||||||
|
d_pts.upload(pts_mat); |
||||||
|
|
||||||
|
ocl::oclMat d_nextPts; |
||||||
|
ocl::oclMat d_status; |
||||||
|
ocl::oclMat d_err; |
||||||
|
|
||||||
|
WARMUP_ON; |
||||||
|
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err); |
||||||
|
WARMUP_OFF; |
||||||
|
|
||||||
|
GPU_ON; |
||||||
|
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err); |
||||||
|
; |
||||||
|
GPU_OFF; |
||||||
|
|
||||||
|
GPU_FULL_ON; |
||||||
|
d_frame0.upload(frame0); |
||||||
|
d_frame1.upload(frame1); |
||||||
|
d_pts.upload(pts_mat); |
||||||
|
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err); |
||||||
|
|
||||||
|
if (!d_nextPts.empty()) |
||||||
|
{ |
||||||
|
d_nextPts.download(nextPts_cpu); |
||||||
|
} |
||||||
|
|
||||||
|
if (!d_status.empty()) |
||||||
|
{ |
||||||
|
d_status.download(status_cpu); |
||||||
|
} |
||||||
|
|
||||||
|
GPU_FULL_OFF; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -1,265 +0,0 @@ |
|||||||
/*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 "precomp.hpp" |
|
||||||
#define VARNAME(A) #A |
|
||||||
using namespace std; |
|
||||||
using namespace cv; |
|
||||||
using namespace cv::gpu; |
|
||||||
using namespace cvtest; |
|
||||||
|
|
||||||
|
|
||||||
//std::string generateVarList(int first,...)
|
|
||||||
//{
|
|
||||||
// vector<std::string> varname;
|
|
||||||
//
|
|
||||||
// va_list argp;
|
|
||||||
// string s;
|
|
||||||
// stringstream ss;
|
|
||||||
// va_start(argp,first);
|
|
||||||
// int i=first;
|
|
||||||
// while(i!=-1)
|
|
||||||
// {
|
|
||||||
// ss<<i<<",";
|
|
||||||
// i=va_arg(argp,int);
|
|
||||||
// };
|
|
||||||
// s=ss.str();
|
|
||||||
// va_end(argp);
|
|
||||||
// return s;
|
|
||||||
//};
|
|
||||||
|
|
||||||
//std::string generateVarList(int& p1,int& p2)
|
|
||||||
//{
|
|
||||||
// stringstream ss;
|
|
||||||
// ss<<VARNAME(p1)<<":"<<src1x<<","<<VARNAME(p2)<<":"<<src1y;
|
|
||||||
// return ss.str();
|
|
||||||
//};
|
|
||||||
|
|
||||||
int randomInt(int minVal, int maxVal) |
|
||||||
{ |
|
||||||
RNG &rng = TS::ptr()->get_rng(); |
|
||||||
return rng.uniform(minVal, maxVal); |
|
||||||
} |
|
||||||
|
|
||||||
double randomDouble(double minVal, double maxVal) |
|
||||||
{ |
|
||||||
RNG &rng = TS::ptr()->get_rng(); |
|
||||||
return rng.uniform(minVal, maxVal); |
|
||||||
} |
|
||||||
|
|
||||||
Size randomSize(int minVal, int maxVal) |
|
||||||
{ |
|
||||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal)); |
|
||||||
} |
|
||||||
|
|
||||||
Scalar randomScalar(double minVal, double maxVal) |
|
||||||
{ |
|
||||||
return Scalar(randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal)); |
|
||||||
} |
|
||||||
|
|
||||||
Mat randomMat(Size size, int type, double minVal, double maxVal) |
|
||||||
{ |
|
||||||
return randomMat(TS::ptr()->get_rng(), size, type, minVal, maxVal, false); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void showDiff(InputArray gold_, InputArray actual_, double eps) |
|
||||||
{ |
|
||||||
Mat gold; |
|
||||||
if (gold_.kind() == _InputArray::MAT) |
|
||||||
gold = gold_.getMat(); |
|
||||||
else |
|
||||||
gold_.getGpuMat().download(gold); |
|
||||||
|
|
||||||
Mat actual; |
|
||||||
if (actual_.kind() == _InputArray::MAT) |
|
||||||
actual = actual_.getMat(); |
|
||||||
else |
|
||||||
actual_.getGpuMat().download(actual); |
|
||||||
|
|
||||||
Mat diff; |
|
||||||
absdiff(gold, actual, diff); |
|
||||||
threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY); |
|
||||||
|
|
||||||
namedWindow("gold", WINDOW_NORMAL); |
|
||||||
namedWindow("actual", WINDOW_NORMAL); |
|
||||||
namedWindow("diff", WINDOW_NORMAL); |
|
||||||
|
|
||||||
imshow("gold", gold); |
|
||||||
imshow("actual", actual); |
|
||||||
imshow("diff", diff); |
|
||||||
|
|
||||||
waitKey(); |
|
||||||
} |
|
||||||
*/ |
|
||||||
|
|
||||||
/*
|
|
||||||
bool supportFeature(const DeviceInfo& info, FeatureSet feature) |
|
||||||
{ |
|
||||||
return TargetArchs::builtWith(feature) && info.supports(feature); |
|
||||||
} |
|
||||||
|
|
||||||
const vector<DeviceInfo>& devices() |
|
||||||
{ |
|
||||||
static vector<DeviceInfo> devs; |
|
||||||
static bool first = true; |
|
||||||
|
|
||||||
if (first) |
|
||||||
{ |
|
||||||
int deviceCount = getCudaEnabledDeviceCount(); |
|
||||||
|
|
||||||
devs.reserve(deviceCount); |
|
||||||
|
|
||||||
for (int i = 0; i < deviceCount; ++i) |
|
||||||
{ |
|
||||||
DeviceInfo info(i); |
|
||||||
if (info.isCompatible()) |
|
||||||
devs.push_back(info); |
|
||||||
} |
|
||||||
|
|
||||||
first = false; |
|
||||||
} |
|
||||||
|
|
||||||
return devs; |
|
||||||
} |
|
||||||
|
|
||||||
vector<DeviceInfo> devices(FeatureSet feature) |
|
||||||
{ |
|
||||||
const vector<DeviceInfo>& d = devices(); |
|
||||||
|
|
||||||
vector<DeviceInfo> devs_filtered; |
|
||||||
|
|
||||||
if (TargetArchs::builtWith(feature)) |
|
||||||
{ |
|
||||||
devs_filtered.reserve(d.size()); |
|
||||||
|
|
||||||
for (size_t i = 0, size = d.size(); i < size; ++i) |
|
||||||
{ |
|
||||||
const DeviceInfo& info = d[i]; |
|
||||||
|
|
||||||
if (info.supports(feature)) |
|
||||||
devs_filtered.push_back(info); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return devs_filtered; |
|
||||||
} |
|
||||||
*/ |
|
||||||
|
|
||||||
vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end) |
|
||||||
{ |
|
||||||
vector<MatType> v; |
|
||||||
|
|
||||||
v.reserve((depth_end - depth_start + 1) * (cn_end - cn_start + 1)); |
|
||||||
|
|
||||||
for (int depth = depth_start; depth <= depth_end; ++depth) |
|
||||||
{ |
|
||||||
for (int cn = cn_start; cn <= cn_end; ++cn) |
|
||||||
{ |
|
||||||
v.push_back(CV_MAKETYPE(depth, cn)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return v; |
|
||||||
} |
|
||||||
|
|
||||||
const vector<MatType> &all_types() |
|
||||||
{ |
|
||||||
static vector<MatType> v = types(CV_8U, CV_64F, 1, 4); |
|
||||||
|
|
||||||
return v; |
|
||||||
} |
|
||||||
|
|
||||||
Mat readImage(const string &fileName, int flags) |
|
||||||
{ |
|
||||||
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags); |
|
||||||
} |
|
||||||
|
|
||||||
Mat readImageType(const string &fname, int type) |
|
||||||
{ |
|
||||||
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR); |
|
||||||
if (CV_MAT_CN(type) == 4) |
|
||||||
{ |
|
||||||
Mat temp; |
|
||||||
cvtColor(src, temp, cv::COLOR_BGR2BGRA); |
|
||||||
swap(src, temp); |
|
||||||
} |
|
||||||
src.convertTo(src, CV_MAT_DEPTH(type)); |
|
||||||
return src; |
|
||||||
} |
|
||||||
|
|
||||||
double checkNorm(const Mat &m) |
|
||||||
{ |
|
||||||
return norm(m, NORM_INF); |
|
||||||
} |
|
||||||
|
|
||||||
double checkNorm(const Mat &m1, const Mat &m2) |
|
||||||
{ |
|
||||||
return norm(m1, m2, NORM_INF); |
|
||||||
} |
|
||||||
|
|
||||||
double checkSimilarity(const Mat &m1, const Mat &m2) |
|
||||||
{ |
|
||||||
Mat diff; |
|
||||||
matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED); |
|
||||||
return std::abs(diff.at<float>(0, 0) - 1.f); |
|
||||||
} |
|
||||||
|
|
||||||
/*
|
|
||||||
void cv::ocl::PrintTo(const DeviceInfo& info, ostream* os) |
|
||||||
{ |
|
||||||
(*os) << info.name(); |
|
||||||
} |
|
||||||
*/ |
|
||||||
|
|
||||||
void PrintTo(const Inverse &inverse, std::ostream *os) |
|
||||||
{ |
|
||||||
if (inverse) |
|
||||||
(*os) << "inverse"; |
|
||||||
else |
|
||||||
(*os) << "direct"; |
|
||||||
} |
|
@ -1,182 +0,0 @@ |
|||||||
/*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*/
|
|
||||||
|
|
||||||
#ifndef __OPENCV_TEST_UTILITY_HPP__ |
|
||||||
#define __OPENCV_TEST_UTILITY_HPP__ |
|
||||||
//#define PRINT_KERNEL_RUN_TIME
|
|
||||||
#ifdef PRINT_KERNEL_RUN_TIME |
|
||||||
#define LOOP_TIMES 1 |
|
||||||
#else |
|
||||||
#define LOOP_TIMES 1 |
|
||||||
#endif |
|
||||||
#define MWIDTH 1920 |
|
||||||
#define MHEIGHT 1080 |
|
||||||
#define CLBINPATH ".\\" |
|
||||||
#define LOOPROISTART 0 |
|
||||||
#define LOOPROIEND 1 |
|
||||||
int randomInt(int minVal, int maxVal); |
|
||||||
double randomDouble(double minVal, double maxVal); |
|
||||||
|
|
||||||
//std::string generateVarList(int first,...);
|
|
||||||
std::string generateVarList(int &p1, int &p2); |
|
||||||
cv::Size randomSize(int minVal, int maxVal); |
|
||||||
cv::Scalar randomScalar(double minVal, double maxVal); |
|
||||||
cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0); |
|
||||||
|
|
||||||
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps); |
|
||||||
|
|
||||||
//! return true if device supports specified feature and gpu module was built with support the feature.
|
|
||||||
//bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
|
|
||||||
|
|
||||||
//! return all devices compatible with current gpu module build.
|
|
||||||
//const std::vector<cv::ocl::DeviceInfo>& devices();
|
|
||||||
//! return all devices compatible with current gpu module build which support specified feature.
|
|
||||||
//std::vector<cv::ocl::DeviceInfo> devices(cv::gpu::FeatureSet feature);
|
|
||||||
|
|
||||||
//! read image from testdata folder.
|
|
||||||
cv::Mat readImage(const std::string &fileName, int flags = cv::IMREAD_COLOR); |
|
||||||
cv::Mat readImageType(const std::string &fname, int type); |
|
||||||
|
|
||||||
double checkNorm(const cv::Mat &m); |
|
||||||
double checkNorm(const cv::Mat &m1, const cv::Mat &m2); |
|
||||||
double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2); |
|
||||||
|
|
||||||
#define EXPECT_MAT_NORM(mat, eps) \ |
|
||||||
{ \
|
|
||||||
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
|
|
||||||
} |
|
||||||
|
|
||||||
/*#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
|
|
||||||
{ \
|
|
||||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
|
||||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
|
||||||
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
|
|
||||||
}*/ |
|
||||||
|
|
||||||
#define EXPECT_MAT_NEAR(mat1, mat2, eps,s) \ |
|
||||||
{ \
|
|
||||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
|
||||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
|
||||||
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps)<<s; \
|
|
||||||
} |
|
||||||
|
|
||||||
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \ |
|
||||||
{ \
|
|
||||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
|
||||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
|
||||||
EXPECT_LE(checkSimilarity(cv::Mat(mat1), cv::Mat(mat2)), eps); \
|
|
||||||
} |
|
||||||
|
|
||||||
namespace cv |
|
||||||
{ |
|
||||||
namespace ocl |
|
||||||
{ |
|
||||||
// void PrintTo(const DeviceInfo& info, std::ostream* os);
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
using perf::MatDepth; |
|
||||||
using perf::MatType; |
|
||||||
|
|
||||||
//! return vector with types from specified range.
|
|
||||||
std::vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end); |
|
||||||
|
|
||||||
//! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).
|
|
||||||
const std::vector<MatType> &all_types(); |
|
||||||
|
|
||||||
class Inverse |
|
||||||
{ |
|
||||||
public: |
|
||||||
inline Inverse(bool val = false) : val_(val) {} |
|
||||||
|
|
||||||
inline operator bool() const |
|
||||||
{ |
|
||||||
return val_; |
|
||||||
} |
|
||||||
|
|
||||||
private: |
|
||||||
bool val_; |
|
||||||
}; |
|
||||||
|
|
||||||
void PrintTo(const Inverse &useRoi, std::ostream *os); |
|
||||||
|
|
||||||
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE) |
|
||||||
|
|
||||||
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX) |
|
||||||
|
|
||||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1}; |
|
||||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y) |
|
||||||
|
|
||||||
CV_ENUM(ReduceOp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) |
|
||||||
|
|
||||||
CV_FLAGS(GemmFlags, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T); |
|
||||||
|
|
||||||
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT) |
|
||||||
|
|
||||||
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV) |
|
||||||
|
|
||||||
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC) |
|
||||||
|
|
||||||
CV_ENUM(Border, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP) |
|
||||||
|
|
||||||
CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WARP_INVERSE_MAP) |
|
||||||
|
|
||||||
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED) |
|
||||||
|
|
||||||
CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT) |
|
||||||
|
|
||||||
void run_perf_test(); |
|
||||||
|
|
||||||
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > > |
|
||||||
|
|
||||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam()) |
|
||||||
|
|
||||||
#define ALL_DEVICES testing::ValuesIn(devices()) |
|
||||||
#define DEVICES(feature) testing::ValuesIn(devices(feature)) |
|
||||||
|
|
||||||
#define ALL_TYPES testing::ValuesIn(all_types()) |
|
||||||
#define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end)) |
|
||||||
|
|
||||||
#define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113)) |
|
||||||
|
|
||||||
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true)) |
|
||||||
|
|
||||||
#endif // __OPENCV_TEST_UTILITY_HPP__
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue