Home | History | Annotate | Download | only in ts
      1 /*M///////////////////////////////////////////////////////////////////////////////////////
      2 //
      3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
      4 //
      5 //  By downloading, copying, installing or using the software you agree to this license.
      6 //  If you do not agree to this license, do not download, install,
      7 //  copy or use the software.
      8 //
      9 //
     10 //                           License Agreement
     11 //                For Open Source Computer Vision Library
     12 //
     13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
     14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
     15 // Third party copyrights are property of their respective owners.
     16 //
     17 // Redistribution and use in source and binary forms, with or without modification,
     18 // are permitted provided that the following conditions are met:
     19 //
     20 //   * Redistribution's of source code must retain the above copyright notice,
     21 //     this list of conditions and the following disclaimer.
     22 //
     23 //   * Redistribution's in binary form must reproduce the above copyright notice,
     24 //     this list of conditions and the following disclaimer in the documentation
     25 //     and/or other materials provided with the distribution.
     26 //
     27 //   * The name of the copyright holders may not be used to endorse or promote products
     28 //     derived from this software without specific prior written permission.
     29 //
     30 // This software is provided by the copyright holders and contributors "as is" and
     31 // any express or implied warranties, including, but not limited to, the implied
     32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
     33 // In no event shall the Intel Corporation or contributors be liable for any direct,
     34 // indirect, incidental, special, exemplary, or consequential damages
     35 // (including, but not limited to, procurement of substitute goods or services;
     36 // loss of use, data, or profits; or business interruption) however caused
     37 // and on any theory of liability, whether in contract, strict liability,
     38 // or tort (including negligence or otherwise) arising in any way out of
     39 // the use of this software, even if advised of the possibility of such damage.
     40 //
     41 //M*/
     42 
     43 #ifndef __OPENCV_CUDA_PERF_UTILITY_HPP__
     44 #define __OPENCV_CUDA_PERF_UTILITY_HPP__
     45 
     46 #include "opencv2/core.hpp"
     47 #include "opencv2/imgcodecs.hpp"
     48 #include "opencv2/videoio.hpp"
     49 #include "opencv2/imgproc.hpp"
     50 #include "opencv2/ts/ts_perf.hpp"
     51 #include "cvconfig.h"
     52 
     53 namespace perf
     54 {
     55     #define ALL_BORDER_MODES BorderMode::all()
     56     #define ALL_INTERPOLATIONS Interpolation::all()
     57 
     58     CV_ENUM(BorderMode, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
     59     CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA)
     60     CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2, NORM_HAMMING, NORM_MINMAX)
     61 
     62     enum { Gray = 1, TwoChannel = 2, BGR = 3, BGRA = 4 };
     63     CV_ENUM(MatCn, Gray, TwoChannel, BGR, BGRA)
     64 
     65     #define CUDA_CHANNELS_1_3_4 testing::Values(MatCn(Gray), MatCn(BGR), MatCn(BGRA))
     66     #define CUDA_CHANNELS_1_3 testing::Values(MatCn(Gray), MatCn(BGR))
     67 
     68     #define GET_PARAM(k) std::tr1::get< k >(GetParam())
     69 
     70     #define DEF_PARAM_TEST(name, ...) typedef ::perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > name
     71     #define DEF_PARAM_TEST_1(name, param_type) typedef ::perf::TestBaseWithParam< param_type > name
     72 
     73     DEF_PARAM_TEST_1(Sz, cv::Size);
     74     typedef perf::Size_MatType Sz_Type;
     75     DEF_PARAM_TEST(Sz_Depth, cv::Size, perf::MatDepth);
     76     DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, perf::MatDepth, MatCn);
     77 
     78     #define CUDA_TYPICAL_MAT_SIZES testing::Values(perf::sz720p, perf::szSXGA, perf::sz1080p)
     79 
     80     #define FAIL_NO_CPU() FAIL() << "No such CPU implementation analogy"
     81 
     82     #define CUDA_SANITY_CHECK(mat, ...) \
     83         do{ \
     84             cv::Mat gpu_##mat(mat); \
     85             SANITY_CHECK(gpu_##mat, ## __VA_ARGS__); \
     86         } while(0)
     87 
     88     #define CPU_SANITY_CHECK(mat, ...) \
     89         do{ \
     90             cv::Mat cpu_##mat(mat); \
     91             SANITY_CHECK(cpu_##mat, ## __VA_ARGS__); \
     92         } while(0)
     93 
     94     CV_EXPORTS cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
     95 
     96     struct CvtColorInfo
     97     {
     98         int scn;
     99         int dcn;
    100         int code;
    101 
    102         CvtColorInfo() {}
    103         explicit CvtColorInfo(int scn_, int dcn_, int code_) : scn(scn_), dcn(dcn_), code(code_) {}
    104     };
    105     CV_EXPORTS void PrintTo(const CvtColorInfo& info, std::ostream* os);
    106 
    107     CV_EXPORTS void printCudaInfo();
    108 
    109     CV_EXPORTS void sortKeyPoints(std::vector<cv::KeyPoint>& keypoints, cv::InputOutputArray _descriptors = cv::noArray());
    110 
    111 #ifdef HAVE_CUDA
    112     #define CV_PERF_TEST_CUDA_MAIN(modulename) \
    113         int main(int argc, char **argv)\
    114         {\
    115             const char * impls[] = { "cuda", "plain" };\
    116             CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, perf::printCudaInfo())\
    117         }
    118 #else
    119     #define CV_PERF_TEST_CUDA_MAIN(modulename) \
    120         int main(int argc, char **argv)\
    121         {\
    122             const char * plain_only[] = { "plain" };\
    123             CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only)\
    124         }
    125 #endif
    126 }
    127 
    128 #endif // __OPENCV_CUDA_PERF_UTILITY_HPP__
    129