2012-07-17 01:08:14 +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.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// License Agreement
|
|
|
|
// For Open Source Computer Vision Library
|
|
|
|
//
|
|
|
|
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
|
|
|
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
2013-05-08 15:21:53 +08:00
|
|
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
2012-07-17 01:08:14 +08:00
|
|
|
// Third party copyrights are property of their respective owners.
|
|
|
|
//
|
|
|
|
// @Authors
|
|
|
|
// Jia Haipeng, jiahaipeng95@gmail.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*/
|
|
|
|
|
2013-08-08 22:18:54 +08:00
|
|
|
#include "test_precomp.hpp"
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_OPENCL
|
|
|
|
|
|
|
|
using namespace cvtest;
|
|
|
|
using namespace testing;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
////////////////////////////////converto/////////////////////////////////////////////////
|
2013-09-11 17:35:39 +08:00
|
|
|
|
|
|
|
PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType, int, bool)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
int src_depth, dst_depth;
|
|
|
|
int cn, dst_type;
|
|
|
|
bool use_roi;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// src mat
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::Mat mat;
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
// set up roi
|
2013-09-11 17:35:39 +08:00
|
|
|
int roicols, roirows;
|
|
|
|
int srcx, srcy;
|
|
|
|
int dstx, dsty;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// src mat with roi
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::Mat mat_roi;
|
|
|
|
cv::Mat dst_roi;
|
2013-05-07 16:14:50 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// ocl dst mat for testing
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::ocl::oclMat gdst_whole;
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// ocl mat with roi
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::ocl::oclMat gsrc;
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::ocl::oclMat gdst;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
src_depth = GET_PARAM(0);
|
|
|
|
dst_depth = GET_PARAM(1);
|
|
|
|
cn = GET_PARAM(2);
|
|
|
|
int src_type = CV_MAKE_TYPE(src_depth, cn);
|
|
|
|
dst_type = CV_MAKE_TYPE(dst_depth, cn);
|
|
|
|
|
|
|
|
use_roi = GET_PARAM(3);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
mat = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), src_type, 5, 136, false);
|
|
|
|
dst = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : mat.size(), dst_type, 5, 136, false);
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void random_roi()
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
if (use_roi)
|
|
|
|
{
|
|
|
|
// randomize ROI
|
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
|
|
|
roicols = rng.uniform(1, MIN_VALUE);
|
|
|
|
roirows = rng.uniform(1, MIN_VALUE);
|
|
|
|
srcx = rng.uniform(0, mat.cols - roicols);
|
|
|
|
srcy = rng.uniform(0, mat.rows - roirows);
|
|
|
|
dstx = rng.uniform(0, dst.cols - roicols);
|
|
|
|
dsty = rng.uniform(0, dst.rows - roirows);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
roicols = mat.cols;
|
|
|
|
roirows = mat.rows;
|
|
|
|
srcx = srcy = 0;
|
|
|
|
dstx = dsty = 0;
|
|
|
|
}
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
mat_roi = mat(Rect(srcx, srcy, roicols, roirows));
|
2013-09-11 17:35:39 +08:00
|
|
|
dst_roi = dst(Rect(dstx, dsty, roicols, roirows));
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
gdst_whole = dst;
|
|
|
|
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
gsrc = mat_roi;
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
typedef ConvertToTestBase ConvertTo;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
TEST_P(ConvertTo, Accuracy)
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
for (int j = 0; j < LOOP_TIMES; j++)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
|
|
|
random_roi();
|
|
|
|
|
|
|
|
mat_roi.convertTo(dst_roi, dst_type);
|
2013-09-20 18:22:18 +08:00
|
|
|
gsrc.convertTo(gdst, dst_type);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
EXPECT_MAT_NEAR(dst, Mat(gdst_whole), src_depth == CV_64F ? 1.0 : 0.0);
|
|
|
|
EXPECT_MAT_NEAR(dst_roi, Mat(gdst), src_depth == CV_64F ? 1.0 : 0.0);
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////copyto/////////////////////////////////////////////////////////////
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
PARAM_TEST_CASE(CopyToTestBase, MatType, int, bool)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
bool use_roi;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::Mat src, mask, dst;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
// set up roi
|
2013-09-20 18:22:18 +08:00
|
|
|
int roicols,roirows;
|
|
|
|
int srcx, srcy;
|
|
|
|
int dstx, dsty;
|
|
|
|
int maskx,masky;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// src mat with roi
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::Mat src_roi;
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::Mat mask_roi;
|
|
|
|
cv::Mat dst_roi;
|
2013-05-07 16:14:50 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// ocl dst mat for testing
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::ocl::oclMat gdst_whole;
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// ocl mat with roi
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::ocl::oclMat gsrc, gdst, gmask;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2013-09-20 18:22:18 +08:00
|
|
|
int type = CV_MAKETYPE(GET_PARAM(0), GET_PARAM(1));
|
|
|
|
use_roi = GET_PARAM(2);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
|
|
|
dst = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), type, 5, 16, false);
|
|
|
|
mask = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void random_roi()
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
if (use_roi)
|
|
|
|
{
|
|
|
|
// randomize ROI
|
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
2013-09-20 18:22:18 +08:00
|
|
|
roicols = rng.uniform(1, MIN_VALUE);
|
|
|
|
roirows = rng.uniform(1, MIN_VALUE);
|
|
|
|
srcx = rng.uniform(0, src.cols - roicols);
|
|
|
|
srcy = rng.uniform(0, src.rows - roirows);
|
|
|
|
dstx = rng.uniform(0, dst.cols - roicols);
|
|
|
|
dsty = rng.uniform(0, dst.rows - roirows);
|
2013-09-11 17:35:39 +08:00
|
|
|
maskx = rng.uniform(0, mask.cols - roicols);
|
|
|
|
masky = rng.uniform(0, mask.rows - roirows);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-20 18:22:18 +08:00
|
|
|
roicols = src.cols;
|
|
|
|
roirows = src.rows;
|
2013-09-11 17:35:39 +08:00
|
|
|
srcx = srcy = 0;
|
|
|
|
dstx = dsty = 0;
|
|
|
|
maskx = masky = 0;
|
|
|
|
}
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src_roi = src(Rect(srcx, srcy, roicols, roirows));
|
2012-07-17 01:08:14 +08:00
|
|
|
mask_roi = mask(Rect(maskx, masky, roicols, roirows));
|
2013-09-11 17:35:39 +08:00
|
|
|
dst_roi = dst(Rect(dstx, dsty, roicols, roirows));
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
gdst_whole = dst;
|
|
|
|
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
gsrc = src_roi;
|
2012-07-17 01:08:14 +08:00
|
|
|
gmask = mask_roi;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
typedef CopyToTestBase CopyTo;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
TEST_P(CopyTo, Without_mask)
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
for (int j = 0; j < LOOP_TIMES; j++)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
|
|
|
random_roi();
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src_roi.copyTo(dst_roi);
|
|
|
|
gsrc.copyTo(gdst);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-05-09 17:57:13 +08:00
|
|
|
EXPECT_MAT_NEAR(dst, Mat(gdst_whole), 0.0);
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CopyTo, With_mask)
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
for (int j = 0; j < LOOP_TIMES; j++)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
|
|
|
random_roi();
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src_roi.copyTo(dst_roi, mask_roi);
|
|
|
|
gsrc.copyTo(gdst, gmask);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-05-09 17:57:13 +08:00
|
|
|
EXPECT_MAT_NEAR(dst, Mat(gdst_whole), 0.0);
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
/////////////////////////////////////////// setTo /////////////////////////////////////////////////////////////
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
PARAM_TEST_CASE(SetToTestBase, MatType, int, bool)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
2013-09-20 18:22:18 +08:00
|
|
|
int depth, channels;
|
2013-09-11 17:35:39 +08:00
|
|
|
bool use_roi;
|
|
|
|
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::Scalar val;
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::Mat src;
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::Mat mask;
|
|
|
|
|
|
|
|
// set up roi
|
2013-09-20 18:22:18 +08:00
|
|
|
int roicols, roirows;
|
|
|
|
int srcx, srcy;
|
|
|
|
int maskx, masky;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// src mat with roi
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::Mat src_roi;
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::Mat mask_roi;
|
2013-05-07 16:14:50 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// ocl dst mat for testing
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::ocl::oclMat gsrc_whole;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// ocl mat with roi
|
2013-09-20 18:22:18 +08:00
|
|
|
cv::ocl::oclMat gsrc;
|
2012-07-17 01:08:14 +08:00
|
|
|
cv::ocl::oclMat gmask;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2013-09-20 18:22:18 +08:00
|
|
|
depth = GET_PARAM(0);
|
|
|
|
channels = GET_PARAM(1);
|
|
|
|
use_roi = GET_PARAM(2);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
2013-09-20 18:22:18 +08:00
|
|
|
int type = CV_MAKE_TYPE(depth, channels);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
|
|
|
mask = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
2013-09-20 18:22:18 +08:00
|
|
|
val = cv::Scalar(rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0),
|
|
|
|
rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0));
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void random_roi()
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
if (use_roi)
|
|
|
|
{
|
|
|
|
// randomize ROI
|
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
2013-09-20 18:22:18 +08:00
|
|
|
roicols = rng.uniform(1, MIN_VALUE);
|
|
|
|
roirows = rng.uniform(1, MIN_VALUE);
|
|
|
|
srcx = rng.uniform(0, src.cols - roicols);
|
|
|
|
srcy = rng.uniform(0, src.rows - roirows);
|
2013-09-11 17:35:39 +08:00
|
|
|
maskx = rng.uniform(0, mask.cols - roicols);
|
|
|
|
masky = rng.uniform(0, mask.rows - roirows);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-20 18:22:18 +08:00
|
|
|
roicols = src.cols;
|
|
|
|
roirows = src.rows;
|
2013-09-11 17:35:39 +08:00
|
|
|
srcx = srcy = 0;
|
|
|
|
maskx = masky = 0;
|
|
|
|
}
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src_roi = src(Rect(srcx, srcy, roicols, roirows));
|
2012-07-17 01:08:14 +08:00
|
|
|
mask_roi = mask(Rect(maskx, masky, roicols, roirows));
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
gsrc_whole = src;
|
|
|
|
gsrc = gsrc_whole(Rect(srcx, srcy, roicols, roirows));
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
gmask = mask_roi;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
typedef SetToTestBase SetTo;
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
TEST_P(SetTo, Without_mask)
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
for (int j = 0; j < LOOP_TIMES; j++)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
|
|
|
random_roi();
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src_roi.setTo(val);
|
|
|
|
gsrc.setTo(val);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
EXPECT_MAT_NEAR(src, Mat(gsrc_whole), 1.);
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(SetTo, With_mask)
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
for (int j = 0; j < LOOP_TIMES; j++)
|
2012-07-17 01:08:14 +08:00
|
|
|
{
|
|
|
|
random_roi();
|
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
src_roi.setTo(val, mask_roi);
|
|
|
|
gsrc.setTo(val, gmask);
|
2012-07-17 01:08:14 +08:00
|
|
|
|
2013-09-20 18:22:18 +08:00
|
|
|
EXPECT_MAT_NEAR(src, Mat(gsrc_whole), 1.);
|
2012-07-17 01:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
// convertC3C4
|
|
|
|
|
|
|
|
PARAM_TEST_CASE(convertC3C4, MatType, bool)
|
2012-08-03 14:08:36 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
int depth;
|
|
|
|
bool use_roi;
|
2012-08-03 14:08:36 +08:00
|
|
|
|
|
|
|
//src mat
|
2013-09-11 17:35:39 +08:00
|
|
|
cv::Mat src;
|
2012-08-03 14:08:36 +08:00
|
|
|
|
|
|
|
// set up roi
|
2013-09-11 17:35:39 +08:00
|
|
|
int roicols, roirows;
|
|
|
|
int srcx, srcy;
|
2012-08-03 14:08:36 +08:00
|
|
|
|
|
|
|
//src mat with roi
|
2013-09-11 17:35:39 +08:00
|
|
|
cv::Mat src_roi;
|
2012-08-03 14:08:36 +08:00
|
|
|
|
|
|
|
//ocl mat with roi
|
2013-09-11 17:35:39 +08:00
|
|
|
cv::ocl::oclMat gsrc_roi;
|
2012-08-03 14:08:36 +08:00
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
depth = GET_PARAM(0);
|
|
|
|
use_roi = GET_PARAM(1);
|
|
|
|
int type = CV_MAKE_TYPE(depth, 3);
|
2012-08-03 14:08:36 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
|
|
|
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 0, 40, false);
|
2012-08-03 14:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void random_roi()
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
if (use_roi)
|
|
|
|
{
|
|
|
|
//randomize ROI
|
|
|
|
cv::RNG &rng = TS::ptr()->get_rng();
|
|
|
|
roicols = rng.uniform(1, src.cols);
|
|
|
|
roirows = rng.uniform(1, src.rows);
|
|
|
|
srcx = rng.uniform(0, src.cols - roicols);
|
|
|
|
srcy = rng.uniform(0, src.rows - roirows);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
roicols = src.cols;
|
|
|
|
roirows = src.rows;
|
|
|
|
srcx = srcy = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
src_roi = src(Rect(srcx, srcy, roicols, roirows));
|
2012-08-03 14:08:36 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(convertC3C4, Accuracy)
|
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
for (int j = 0; j < LOOP_TIMES; j++)
|
2012-08-03 14:08:36 +08:00
|
|
|
{
|
2013-09-11 17:35:39 +08:00
|
|
|
random_roi();
|
2012-08-03 14:08:36 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
gsrc_roi = src_roi;
|
2013-05-09 17:57:13 +08:00
|
|
|
|
2013-09-11 17:35:39 +08:00
|
|
|
EXPECT_MAT_NEAR(src_roi, Mat(gsrc_roi), 0.0);
|
2012-08-03 14:08:36 +08:00
|
|
|
}
|
|
|
|
}
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(MatrixOperation, ConvertTo, Combine(
|
2013-09-11 17:35:39 +08:00
|
|
|
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
|
|
|
|
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
|
|
|
|
Range(1, 5), Bool()));
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(MatrixOperation, CopyTo, Combine(
|
2013-09-20 18:22:18 +08:00
|
|
|
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
|
|
|
|
testing::Range(1, 5), Bool()));
|
2012-07-17 01:08:14 +08:00
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(MatrixOperation, SetTo, Combine(
|
2013-09-20 18:22:18 +08:00
|
|
|
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
|
|
|
|
testing::Range(1, 5), Bool()));
|
2012-08-03 14:08:36 +08:00
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(MatrixOperation, convertC3C4, Combine(
|
2013-09-11 17:35:39 +08:00
|
|
|
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
|
|
|
|
Bool()));
|
2012-07-17 01:08:14 +08:00
|
|
|
#endif
|