/*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. // 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*/ #include "precomp.hpp" #ifdef HAVE_OPENCL using namespace cvtest; using namespace testing; using namespace std; using namespace cv::ocl; ////////////////////////////////converto///////////////////////////////////////////////// PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType) { int type; int dst_type; //src mat cv::Mat mat; cv::Mat dst; // set up roi int roicols; int roirows; int srcx; int srcy; int dstx; int dsty; //src mat with roi cv::Mat mat_roi; cv::Mat dst_roi; //std::vector oclinfo; //ocl dst mat for testing cv::ocl::oclMat gdst_whole; //ocl mat with roi cv::ocl::oclMat gmat; cv::ocl::oclMat gdst; virtual void SetUp() { type = GET_PARAM(0); dst_type = GET_PARAM(1); cv::RNG& rng = TS::ptr()->get_rng(); cv::Size size(MWIDTH, MHEIGHT); mat = randomMat(rng, size, type, 5, 16, false); dst = randomMat(rng, size, type, 5, 16, false); //int devnums = getDevice(oclinfo); //CV_Assert(devnums > 0); ////if you want to use undefault device, set it here ////setDevice(oclinfo[0]); //setBinpath(CLBINPATH); } void Has_roi(int b) { //cv::RNG& rng = TS::ptr()->get_rng(); if(b) { //randomize ROI roicols = mat.cols-1; //start roirows = mat.rows-1; srcx = 1; srcy = 1; dstx = 1; dsty =1; }else { roicols = mat.cols; roirows = mat.rows; srcx = 0; srcy = 0; dstx = 0; dsty = 0; }; mat_roi = mat(Rect(srcx,srcy,roicols,roirows)); dst_roi = dst(Rect(dstx,dsty,roicols,roirows)); //gdst_whole = dst; //gdst = gdst_whole(Rect(dstx,dsty,roicols,roirows)); //gmat = mat_roi; } }; struct ConvertTo :ConvertToTestBase {}; TEST_P(ConvertTo, Accuracy) { #ifndef PRINT_KERNEL_RUN_TIME double totalcputick=0; double totalgputick=0; double totalgputick_kernel=0; double t0=0; double t1=0; double t2=0; for(int k=LOOPROISTART;k oclinfo; //ocl dst mat for testing cv::ocl::oclMat gdst_whole; //ocl mat with roi cv::ocl::oclMat gmat; cv::ocl::oclMat gdst; cv::ocl::oclMat gmask; virtual void SetUp() { type = GET_PARAM(0); cv::RNG& rng = TS::ptr()->get_rng(); cv::Size size(MWIDTH, MHEIGHT); mat = randomMat(rng, size, type, 5, 16, false); dst = randomMat(rng, size, type, 5, 16, false); mask = randomMat(rng, size, CV_8UC1, 0, 2, false); cv::threshold(mask, mask, 0.5, 255., CV_8UC1); //int devnums = getDevice(oclinfo); //CV_Assert(devnums > 0); ////if you want to use undefault device, set it here ////setDevice(oclinfo[0]); //setBinpath(CLBINPATH); } void Has_roi(int b) { //cv::RNG& rng = TS::ptr()->get_rng(); if(b) { //randomize ROI roicols = mat.cols-1; //start roirows = mat.rows-1; srcx = 1; srcy = 1; dstx = 1; dsty =1; maskx = 1; masky = 1; }else { roicols = mat.cols; roirows = mat.rows; srcx = 0; srcy = 0; dstx = 0; dsty = 0; maskx = 0; masky = 0; }; mat_roi = mat(Rect(srcx,srcy,roicols,roirows)); mask_roi = mask(Rect(maskx,masky,roicols,roirows)); dst_roi = dst(Rect(dstx,dsty,roicols,roirows)); //gdst_whole = dst; //gdst = gdst_whole(Rect(dstx,dsty,roicols,roirows)); //gmat = mat_roi; //gmask = mask_roi; } }; struct CopyTo :CopyToTestBase {}; TEST_P(CopyTo, Without_mask) { #ifndef PRINT_KERNEL_RUN_TIME double totalcputick=0; double totalgputick=0; double totalgputick_kernel=0; double t0=0; double t1=0; double t2=0; for(int k=LOOPROISTART;k oclinfo; //ocl dst mat for testing cv::ocl::oclMat gmat_whole; //ocl mat with roi cv::ocl::oclMat gmat; cv::ocl::oclMat gmask; virtual void SetUp() { type = GET_PARAM(0); cv::RNG& rng = TS::ptr()->get_rng(); cv::Size size(MWIDTH, MHEIGHT); mat = randomMat(rng, size, type, 5, 16, false); mask = randomMat(rng, size, CV_8UC1, 0, 2, false); cv::threshold(mask, mask, 0.5, 255., CV_8UC1); 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)); //int devnums = getDevice(oclinfo); //CV_Assert(devnums > 0); ////if you want to use undefault device, set it here ////setDevice(oclinfo[0]); //setBinpath(CLBINPATH); } void Has_roi(int b) { //cv::RNG& rng = TS::ptr()->get_rng(); if(b) { //randomize ROI roicols = mat.cols-1; //start roirows = mat.rows-1; srcx = 1; srcy = 1; maskx = 1; masky = 1; }else { roicols = mat.cols; roirows = mat.rows; srcx = 0; srcy = 0; maskx = 0; masky = 0; }; mat_roi = mat(Rect(srcx,srcy,roicols,roirows)); mask_roi = mask(Rect(maskx,masky,roicols,roirows)); //gmat_whole = mat; //gmat = gmat_whole(Rect(srcx,srcy,roicols,roirows)); //gmask = mask_roi; } }; struct SetTo :SetToTestBase {}; TEST_P(SetTo, Without_mask) { #ifndef PRINT_KERNEL_RUN_TIME double totalcputick=0; double totalgputick=0; double totalgputick_kernel=0; double t0=0; double t1=0; double t2=0; for(int k=LOOPROISTART;k