Merge branch '2.4'
This commit is contained in:
@@ -38,6 +38,15 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __OPENCV_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||
|
||||
|
||||
@@ -1110,8 +1110,8 @@ TEST_P(Phase, Mat)
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
random_roi();
|
||||
cv::phase(mat1_roi, mat2_roi, dst_roi, angelInDegrees);
|
||||
cv::ocl::phase(gmat1, gmat2, gdst, angelInDegrees);
|
||||
cv::phase(mat1_roi, mat2_roi, dst_roi, angelInDegrees ? true : false);
|
||||
cv::ocl::phase(gmat1, gmat2, gdst, angelInDegrees ? true : false);
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
gdst_whole.download(cpu_dst);
|
||||
@@ -1449,8 +1449,8 @@ TEST_P(MagnitudeSqr, Mat)
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
// random_roi();
|
||||
int64 start, end;
|
||||
start = cv::getTickCount();
|
||||
// int64 start, end;
|
||||
// start = cv::getTickCount();
|
||||
for(int i = 0; i < mat1.rows; ++i)
|
||||
for(int j = 0; j < mat1.cols; ++j)
|
||||
{
|
||||
@@ -1465,7 +1465,7 @@ TEST_P(MagnitudeSqr, Mat)
|
||||
|
||||
// ((float *)(dst.data))[i*dst.step/4 +j]= val1 * val1 +val2 * val2;
|
||||
}
|
||||
end = cv::getTickCount();
|
||||
// end = cv::getTickCount();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ TEST_P(Blend, Accuracy)
|
||||
else
|
||||
blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);
|
||||
|
||||
EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1 : 1e-5f, NULL)
|
||||
EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.f : 1e-5f, 0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, Combine(
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/*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
|
||||
// Peng Xiao, pengxiao@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"
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
//#define MAT_DEBUG
|
||||
#ifdef MAT_DEBUG
|
||||
#define MAT_DIFF(mat, mat2)\
|
||||
{\
|
||||
for(int i = 0; i < mat.rows; i ++)\
|
||||
{\
|
||||
for(int j = 0; j < mat.cols; j ++)\
|
||||
{\
|
||||
cv::Vec4b s = mat.at<cv::Vec4b>(i, j);\
|
||||
cv::Vec4b s2 = mat2.at<cv::Vec4b>(i, j);\
|
||||
if(s != s2) printf("*");\
|
||||
else printf(".");\
|
||||
}\
|
||||
puts("\n");\
|
||||
}\
|
||||
}
|
||||
#else
|
||||
#define MAT_DIFF(mat, mat2)
|
||||
#endif
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cvtColor
|
||||
PARAM_TEST_CASE(CvtColor, cv::Size, MatDepth)
|
||||
{
|
||||
cv::Size size;
|
||||
int depth;
|
||||
bool useRoi;
|
||||
|
||||
cv::Mat img;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
size = GET_PARAM(0);
|
||||
depth = GET_PARAM(1);
|
||||
|
||||
img = randomMat(size, CV_MAKE_TYPE(depth, 3), 0.0, depth == CV_32F ? 1.0 : 255.0);
|
||||
}
|
||||
};
|
||||
|
||||
#define CVTCODE(name) cv::COLOR_ ## name
|
||||
#define TEST_P_CVTCOLOR(name) TEST_P(CvtColor, name)\
|
||||
{\
|
||||
cv::Mat src = img;\
|
||||
cv::ocl::oclMat ocl_img, dst;\
|
||||
ocl_img.upload(img);\
|
||||
cv::ocl::cvtColor(ocl_img, dst, CVTCODE(name));\
|
||||
cv::Mat dst_gold;\
|
||||
cv::cvtColor(src, dst_gold, CVTCODE(name));\
|
||||
cv::Mat dst_mat;\
|
||||
dst.download(dst_mat);\
|
||||
EXPECT_MAT_NEAR(dst_gold, dst_mat, 1e-5, "");\
|
||||
}
|
||||
|
||||
//add new ones here using macro
|
||||
TEST_P_CVTCOLOR(RGB2GRAY)
|
||||
TEST_P_CVTCOLOR(BGR2GRAY)
|
||||
TEST_P_CVTCOLOR(RGBA2GRAY)
|
||||
TEST_P_CVTCOLOR(BGRA2GRAY)
|
||||
|
||||
TEST_P_CVTCOLOR(RGB2YUV)
|
||||
TEST_P_CVTCOLOR(BGR2YUV)
|
||||
TEST_P_CVTCOLOR(YUV2RGB)
|
||||
TEST_P_CVTCOLOR(YUV2BGR)
|
||||
TEST_P_CVTCOLOR(RGB2YCrCb)
|
||||
TEST_P_CVTCOLOR(BGR2YCrCb)
|
||||
|
||||
PARAM_TEST_CASE(CvtColor_Gray2RGB, cv::Size, MatDepth, int)
|
||||
{
|
||||
cv::Size size;
|
||||
int code;
|
||||
int depth;
|
||||
cv::Mat img;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
size = GET_PARAM(0);
|
||||
depth = GET_PARAM(1);
|
||||
code = GET_PARAM(2);
|
||||
img = randomMat(size, CV_MAKETYPE(depth, 1), 0.0, depth == CV_32F ? 1.0 : 255.0);
|
||||
}
|
||||
};
|
||||
TEST_P(CvtColor_Gray2RGB, Accuracy)
|
||||
{
|
||||
cv::Mat src = img;
|
||||
cv::ocl::oclMat ocl_img, dst;
|
||||
ocl_img.upload(src);
|
||||
cv::ocl::cvtColor(ocl_img, dst, code);
|
||||
cv::Mat dst_gold;
|
||||
cv::cvtColor(src, dst_gold, code);
|
||||
cv::Mat dst_mat;
|
||||
dst.download(dst_mat);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst_mat, 1e-5, "");
|
||||
}
|
||||
|
||||
|
||||
PARAM_TEST_CASE(CvtColor_YUV420, cv::Size, int)
|
||||
{
|
||||
cv::Size size;
|
||||
int code;
|
||||
|
||||
cv::Mat img;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
size = GET_PARAM(0);
|
||||
code = GET_PARAM(1);
|
||||
img = randomMat(size, CV_8UC1, 0.0, 255.0);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(CvtColor_YUV420, Accuracy)
|
||||
{
|
||||
cv::Mat src = img;
|
||||
cv::ocl::oclMat ocl_img, dst;
|
||||
ocl_img.upload(src);
|
||||
cv::ocl::cvtColor(ocl_img, dst, code);
|
||||
cv::Mat dst_gold;
|
||||
cv::cvtColor(src, dst_gold, code);
|
||||
cv::Mat dst_mat;
|
||||
dst.download(dst_mat);
|
||||
MAT_DIFF(dst_mat, dst_gold);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst_mat, 1e-5, "");
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor, testing::Combine(
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F))
|
||||
));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor_YUV420, testing::Combine(
|
||||
testing::Values(cv::Size(128, 45), cv::Size(46, 132), cv::Size(1024, 1023)),
|
||||
testing::Values((int)CV_YUV2RGBA_NV12, (int)CV_YUV2BGRA_NV12, (int)CV_YUV2RGB_NV12, (int)CV_YUV2BGR_NV12)
|
||||
));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor_Gray2RGB, testing::Combine(
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)),
|
||||
testing::Values((int)CV_GRAY2BGR, (int)CV_GRAY2BGRA, (int)CV_GRAY2RGB, (int)CV_GRAY2RGBA)
|
||||
));
|
||||
}
|
||||
#endif
|
||||
@@ -109,15 +109,15 @@ TEST_F(Haar, FaceDetect)
|
||||
//double t = 0;
|
||||
vector<Rect> faces, oclfaces;
|
||||
|
||||
const static Scalar colors[] = { CV_RGB(0, 0, 255),
|
||||
CV_RGB(0, 128, 255),
|
||||
CV_RGB(0, 255, 255),
|
||||
CV_RGB(0, 255, 0),
|
||||
CV_RGB(255, 128, 0),
|
||||
CV_RGB(255, 255, 0),
|
||||
CV_RGB(255, 0, 0),
|
||||
CV_RGB(255, 0, 255)
|
||||
} ;
|
||||
// const static Scalar colors[] = { CV_RGB(0, 0, 255),
|
||||
// CV_RGB(0, 128, 255),
|
||||
// CV_RGB(0, 255, 255),
|
||||
// CV_RGB(0, 255, 0),
|
||||
// CV_RGB(255, 128, 0),
|
||||
// CV_RGB(255, 255, 0),
|
||||
// CV_RGB(255, 0, 0),
|
||||
// CV_RGB(255, 0, 255)
|
||||
// } ;
|
||||
|
||||
Mat gray, smallImg(cvRound (img.rows / scale), cvRound(img.cols / scale), CV_8UC1 );
|
||||
MemStorage storage(cvCreateMemStorage(0));
|
||||
|
||||
@@ -498,11 +498,11 @@ TEST_P(bilateralFilter, Mat)
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < sizeof(bordertype) / sizeof(int); i++)
|
||||
for(size_t i = 0; i < sizeof(bordertype) / sizeof(int); i++)
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
random_roi();
|
||||
if(((bordertype[i] != cv::BORDER_CONSTANT) && (bordertype[i] != cv::BORDER_REPLICATE)) && (mat1_roi.cols <= radius) || (mat1_roi.cols <= radius) || (mat1_roi.rows <= radius) || (mat1_roi.rows <= radius))
|
||||
if(((bordertype[i] != cv::BORDER_CONSTANT) && (bordertype[i] != cv::BORDER_REPLICATE) && (mat1_roi.cols <= radius)) || (mat1_roi.cols <= radius) || (mat1_roi.rows <= radius) || (mat1_roi.rows <= radius))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -563,7 +563,7 @@ TEST_P(CopyMakeBorder, Mat)
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < sizeof(bordertype) / sizeof(int); i++)
|
||||
for(size_t i = 0; i < sizeof(bordertype) / sizeof(int); i++)
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
random_roi();
|
||||
@@ -911,7 +911,6 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size srcSize = cv::Size(MWIDTH, MHEIGHT);
|
||||
cv::Size dstSize = cv::Size(MWIDTH, MHEIGHT);
|
||||
cv::Size map1Size = cv::Size(MWIDTH, MHEIGHT);
|
||||
double min = 5, max = 16;
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ TEST_P(MatchTemplate8U, Accuracy)
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1, sss);
|
||||
|
||||
#if PERF_TEST
|
||||
#ifdef PERF_TEST
|
||||
{
|
||||
P_TEST_FULL( {}, {cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);}, {});
|
||||
P_TEST_FULL( {}, {cv::matchTemplate(image, templ, dst_gold, method);}, {});
|
||||
@@ -145,7 +145,7 @@ TEST_P(MatchTemplate32F, Accuracy)
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1, sss);
|
||||
|
||||
#if PERF_TEST
|
||||
#ifdef PERF_TEST
|
||||
{
|
||||
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl;
|
||||
std::cout << "Image Size: (" << size.width << ", " << size.height << ")" << std::endl;
|
||||
|
||||
@@ -118,9 +118,9 @@ TEST_P(Sparse, Mat)
|
||||
cv::Mat status_mat(1, d_status.cols, CV_8UC1, (void *)&status[0]);
|
||||
d_status.download(status_mat);
|
||||
|
||||
//std::vector<float> err(d_err.cols);
|
||||
//cv::Mat err_mat(1, d_err.cols, CV_32FC1, (void*)&err[0]);
|
||||
//d_err.download(err_mat);
|
||||
std::vector<float> err(d_err.cols);
|
||||
cv::Mat err_mat(1, d_err.cols, CV_32FC1, (void*)&err[0]);
|
||||
d_err.download(err_mat);
|
||||
|
||||
std::vector<cv::Point2f> nextPts_gold;
|
||||
std::vector<unsigned char> status_gold;
|
||||
@@ -153,9 +153,9 @@ TEST_P(Sparse, Mat)
|
||||
}
|
||||
}
|
||||
|
||||
double bad_ratio = static_cast<double>(mistmatch) / (nextPts.size() * 2);
|
||||
double bad_ratio = static_cast<double>(mistmatch) / (nextPts.size());
|
||||
|
||||
ASSERT_LE(bad_ratio, 0.05f);
|
||||
ASSERT_LE(bad_ratio, 0.02f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@ double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
|
||||
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) \
|
||||
{ \
|
||||
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) \
|
||||
{ \
|
||||
|
||||
Reference in New Issue
Block a user