1 #ifndef __OPENCV_GTESTCV_HPP__
2 #define __OPENCV_GTESTCV_HPP__
7 #pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
11 #pragma warning( disable: 4127 )
14 #define GTEST_DONT_DEFINE_FAIL 0
15 #define GTEST_DONT_DEFINE_SUCCEED 0
16 #define GTEST_DONT_DEFINE_ASSERT_EQ 0
17 #define GTEST_DONT_DEFINE_ASSERT_NE 0
18 #define GTEST_DONT_DEFINE_ASSERT_LE 0
19 #define GTEST_DONT_DEFINE_ASSERT_LT 0
20 #define GTEST_DONT_DEFINE_ASSERT_GE 0
21 #define GTEST_DONT_DEFINE_ASSERT_GT 0
22 #define GTEST_DONT_DEFINE_TEST 0
26 #ifndef GTEST_USES_SIMPLE_RE
27 # define GTEST_USES_SIMPLE_RE 0
29 #ifndef GTEST_USES_POSIX_RE
30 # define GTEST_USES_POSIX_RE 0
65 CV_EXPORTS
int typeByName(
const char* type_name );
67 CV_EXPORTS
string vec2str(
const string& sep,
const int*
v,
size_t nelems);
82 CV_EXPORTS
void randomSize(RNG&
rng,
int minDims,
int maxDims,
double maxSizeLog, vector<int>& sz);
83 CV_EXPORTS
int randomType(RNG&
rng,
int typeMask,
int minChannels,
int maxChannels);
85 CV_EXPORTS Mat
randomMat(RNG&
rng,
const vector<int>&
size,
int type,
double minVal,
double maxVal,
bool useRoi);
86 CV_EXPORTS
void add(
const Mat&
a,
double alpha,
const Mat&
b,
double beta,
88 CV_EXPORTS
void multiply(
const Mat&
a,
const Mat&
b, Mat&
c,
double alpha=1);
89 CV_EXPORTS
void divide(
const Mat&
a,
const Mat&
b, Mat&
c,
double alpha=1);
92 CV_EXPORTS
void copy(
const Mat&
src, Mat&
dst,
const Mat&
mask=Mat(),
bool invertMask=
false);
96 CV_EXPORTS
void extract(
const Mat&
a, Mat& plane,
int coi );
97 CV_EXPORTS
void insert(
const Mat& plane, Mat&
a,
int coi );
106 CV_EXPORTS
void transpose(
const Mat& src, Mat& dst);
107 CV_EXPORTS
void erode(
const Mat& src, Mat& dst,
const Mat& _kernel,
Point anchor=
Point(-1,-1),
108 int borderType=IPL_BORDER_CONSTANT,
const Scalar& borderValue=
Scalar());
109 CV_EXPORTS
void dilate(
const Mat& src, Mat& dst,
const Mat& _kernel,
Point anchor=
Point(-1,-1),
110 int borderType=IPL_BORDER_CONSTANT,
const Scalar& borderValue=
Scalar());
111 CV_EXPORTS
void filter2D(
const Mat& src, Mat& dst,
int ddepth,
const Mat&
kernel,
121 CV_EXPORTS
void minMaxLoc(
const Mat& src,
double* minval,
double* maxval,
122 vector<int>* minloc, vector<int>* maxloc,
const Mat&
mask=Mat());
123 CV_EXPORTS
double norm(
const Mat& src,
int normType,
const Mat&
mask=Mat());
124 CV_EXPORTS
double norm(
const Mat&
src1,
const Mat&
src2,
int normType,
const Mat&
mask=Mat());
127 CV_EXPORTS
bool cmpUlps(
const Mat&
data,
const Mat& refdata,
int expMaxDiff,
double* realMaxDiff, vector<int>*
idx);
133 CV_EXPORTS
int cmpEps(
const Mat&
data,
const Mat& refdata,
double* max_diff,
134 double success_err_level, vector<int>*
idx,
135 bool element_wise_relative_error );
138 CV_EXPORTS
int cmpEps2(
TS* ts,
const Mat&
data,
const Mat& refdata,
double success_err_level,
139 bool element_wise_relative_error,
const char* desc );
142 double eps,
const char* param_name );
144 CV_EXPORTS
void logicOp(
const Mat& src1,
const Mat& src2, Mat& dst,
char c);
145 CV_EXPORTS
void logicOp(
const Mat& src,
const Scalar&
s, Mat& dst,
char c);
146 CV_EXPORTS
void min(
const Mat& src1,
const Mat& src2, Mat& dst);
147 CV_EXPORTS
void min(
const Mat& src,
double s, Mat& dst);
148 CV_EXPORTS
void max(
const Mat& src1,
const Mat& src2, Mat& dst);
149 CV_EXPORTS
void max(
const Mat& src,
double s, Mat& dst);
151 CV_EXPORTS
void compare(
const Mat& src1,
const Mat& src2, Mat& dst,
int cmpop);
152 CV_EXPORTS
void compare(
const Mat& src,
double s, Mat& dst,
int cmpop);
153 CV_EXPORTS
void gemm(
const Mat& src1,
const Mat& src2,
double alpha,
155 CV_EXPORTS
void transform(
const Mat& src, Mat& dst,
const Mat&
transmat,
const Mat& shift );
156 CV_EXPORTS
double crossCorr(
const Mat& src1,
const Mat& src2);
172 const Mat& m1,
const Mat& m2);
193 virtual void run(
int start_from );
196 virtual void safe_run(
int start_from=0 );
202 virtual bool can_do_fast_forward();
206 virtual void clear();
215 virtual int get_test_case_count();
218 virtual int prepare_test_case(
int test_case_idx );
221 virtual int validate_test_results(
int test_case_idx );
224 virtual void run_func();
227 virtual int update_progress(
int progress,
int test_case_idx,
int count,
double dt );
295 SUMMARY=1 << SUMMARY_IDX,
301 CONSOLE=1 << CONSOLE_IDX,
308 virtual void init(
const string& modulename );
311 virtual void printf(
int streams,
const char* fmt, ... );
312 virtual void vprintf(
int streams,
const char* fmt, va_list arglist );
315 virtual void update_context(
BaseTest* test,
int test_case_idx,
bool update_ts_context );
320 virtual void set_failed_test_info(
int fail_code );
322 virtual void set_gtest_status();
335 FAIL_MISSING_TEST_DATA=-2,
338 FAIL_ERROR_IN_CALLED_FUNC=-3,
347 FAIL_MEMORY_EXCEPTION=-5,
350 FAIL_ARITHM_EXCEPTION=-6,
353 FAIL_MEMORY_CORRUPTION_BEGIN=-7,
354 FAIL_MEMORY_CORRUPTION_END=-8,
361 FAIL_INVALID_OUTPUT=-10,
369 FAIL_BAD_ACCURACY=-12,
378 FAIL_BAD_ARG_CHECK=-14,
381 FAIL_INVALID_TEST_DATA=-15,
406 static string str_from_code(
int code );
420 std::string output_buf[MAX_IDX];
435 virtual void clear();
440 virtual int prepare_test_case(
int test_case_idx );
441 virtual int validate_test_results(
int test_case_idx );
443 virtual void prepare_to_validation(
int test_case_idx );
444 virtual void get_test_array_types_and_sizes(
int test_case_idx, vector<vector<Size> >&
sizes, vector<vector<int> >&
types );
445 virtual void fill_array(
int test_case_idx,
int i,
int j,
Mat&
arr );
446 virtual void get_minmax_bounds(
int i,
int j,
int type,
Scalar& low,
Scalar& high );
447 virtual double get_success_error_level(
int test_case_idx,
int i,
int j );
457 enum {
INPUT, INPUT_OUTPUT,
OUTPUT, REF_INPUT_OUTPUT, REF_OUTPUT,
TEMP, MASK, MAX_ARR };
473 virtual int run_test_case(
int expected_code,
const string& descr );
474 virtual void run_func(
void) = 0;
483 if( test_case_idx < 0 )
491 dt = (new_t -
t)/(freq*1000);
494 progress = update_progress(progress, test_case_idx, 0,
dt);
498 const char* descr = _descr.c_str() ? _descr.c_str() :
"";
507 if( e.
code != expected_code )
509 ts->printf(
TS::LOG,
"%s (test case #%d): the error code %d is different from the expected %d\n",
510 descr, test_case_idx, e.
code, expected_code);
517 ts->printf(
TS::LOG,
"%s (test case #%d): unknown exception was thrown (the function has likely crashed)\n",
518 descr, test_case_idx);
523 ts->printf(
TS::LOG,
"%s (test case #%d): no expected exception was thrown\n",
524 descr, test_case_idx);
567 #ifndef __CV_TEST_EXEC_ARGS
568 #if defined(_MSC_VER) && (_MSC_VER <= 1400)
569 #define __CV_TEST_EXEC_ARGS(...) \
570 while (++argc >= (--argc,-1)) {__VA_ARGS__; break;}
572 #define __CV_TEST_EXEC_ARGS(...) \
577 #define CV_TEST_MAIN(resourcesubdir, ...) \
578 int main(int argc, char **argv) \
580 cvtest::TS::ptr()->init(resourcesubdir); \
581 ::testing::InitGoogleTest(&argc, argv); \
582 cvtest::printVersionInfo(); \
583 __CV_TEST_EXEC_ARGS(__VA_ARGS__) \
584 return RUN_ALL_TESTS(); \
589 #define CV_TEST_FAIL_NO_IMPL() do { \
590 ::testing::Test::RecordProperty("custom_status", "noimpl"); \
591 FAIL() << "No equivalent implementation."; \
const Mat * m
Definition: ts.hpp:161
double * min_val
Definition: core_c.h:833
Point2i Point
Definition: core.hpp:893
CV_EXPORTS const char * getTypeName(int type)
CV_EXPORTS void gemm(const Mat &src1, const Mat &src2, double alpha, const Mat &src3, double beta, Mat &dst, int flags)
CV_EXPORTS void divide(const Mat &a, const Mat &b, Mat &c, double alpha=1)
Random Number Generator.
Definition: core.hpp:2019
const int * sizes
Definition: core_c.h:212
bool use_optimized
Definition: ts.hpp:277
GLdouble GLdouble GLdouble GLdouble top
GLint level
Definition: tracking.hpp:88
const string & get_data_path() const
Definition: ts.hpp:403
bool optional_mask
Definition: ts.hpp:451
bool element_wise_relative_error
Definition: ts.hpp:452
CV_EXPORTS void copy(const Mat &src, Mat &dst, const Mat &mask=Mat(), bool invertMask=false)
CV_EXPORTS void dilate(const Mat &src, Mat &dst, const Mat &_kernel, Point anchor=Point(-1,-1), int borderType=IPL_BORDER_CONSTANT, const Scalar &borderValue=Scalar())
CV_EXPORTS Mat calcLaplaceKernel2D(int aperture_size)
CV_EXPORTS void cvTsConvert(const CvMat *src, CvMat *dst)
Size2i Size
Definition: core.hpp:896
int clipInt(int val, int min_val, int max_val)
Definition: ts.hpp:69
class CV_EXPORTS TS
Definition: ts.hpp:47
CV_EXPORTS void patchZeros(Mat &mat, double level)
const int * idx
Definition: core_c.h:323
int max_log_array_size
Definition: ts.hpp:455
const CvArr * src1
Definition: core_c.h:436
GLuint src
Definition: core_c.h:1650
CV_EXPORTS Mat calcSobelKernel2D(int dx, int dy, int apertureSize, int origin=0)
int int int flags
Definition: highgui_c.h:186
CV_EXPORTS double getMinVal(int depth)
TSParams params
Definition: ts.hpp:419
CV_EXPORTS void min(const Mat &src1, const Mat &src2, Mat &dst)
uint64 rng_seed0
Definition: ts.hpp:258
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: core_c.h:403
int d
Definition: legacy.hpp:3064
CV_EXPORTS bool cmpUlps(const Mat &data, const Mat &refdata, int expMaxDiff, double *realMaxDiff, vector< int > *idx)
const string & get_name() const
Definition: ts.hpp:198
double realmaxdiff
Definition: ts.hpp:175
uint64 rng_seed
Definition: ts.hpp:274
CV_EXPORTS double norm(const Mat &src, int normType, const Mat &mask=Mat())
CvArr const CvMat * kernel
Definition: imgproc_c.h:89
CvRNG * rng
Definition: core_c.h:652
CV_EXPORTS RNG & theRNG()
returns the thread-local Random number generator
int CvMemStorage int double eps
Definition: imgproc_c.h:353
uint64 state
Definition: core.hpp:2050
CV_EXPORTS int cmpEps(const Mat &data, const Mat &refdata, double *max_diff, double success_err_level, vector< int > *idx, bool element_wise_relative_error)
CV_EXPORTS string vec2str(const string &sep, const int *v, size_t nelems)
BaseTest * test
Definition: ts.hpp:249
void clear(const ColorA &color=ColorA::black(), bool clearDepthBuffer=true)
int test_case_idx
Definition: ts.hpp:475
CV_EXPORTS void transform(const Mat &src, Mat &dst, const Mat &transmat, const Mat &shift)
const char const char * str
Definition: core_c.h:1552
CV_EXPORTS cv::Mat randomMat(cv::Size size, int type, double minVal=0.0, double maxVal=255.0)
CV_EXPORTS void set(Mat &dst, const Scalar &gamma, const Mat &mask=Mat())
string name
Definition: ts.hpp:233
CV_EXPORTS void cvTsZero(CvMat *c, const CvMat *mask=0)
CvArr const CvArr const CvArr * mapy
Definition: imgproc_c.h:176
~DefaultRngAuto()
Definition: ts.hpp:538
uint64 rng_seed
Definition: ts.hpp:255
const char * name
Definition: core_c.h:1538
GLint GLvoid * img
Definition: legacy.hpp:1150
CvArr const CvMat * transmat
Definition: core_c.h:694
CvArr const CvArr * mapx
Definition: imgproc_c.h:176
CV_EXPORTS int randomType(RNG &rng, int typeMask, int minChannels, int maxChannels)
const CvArr const CvArr const CvArr * src3
Definition: core_c.h:436
CV_EXPORTS int typeByName(const char *type_name)
CvArr const CvMat * mat
Definition: core_c.h:700
int test_case_count
Definition: ts.hpp:209
CV_EXPORTS int cmpEps2(TS *ts, const Mat &data, const Mat &refdata, double success_err_level, bool element_wise_relative_error, const char *desc)
GLclampf GLclampf GLclampf alpha
Definition: core_c.h:687
double get_test_case_count_scale()
Definition: ts.hpp:401
CV_EXPORTS void fillGradient(Mat &img, int delta=5)
int min_log_array_size
Definition: ts.hpp:454
int coi
Definition: core_c.h:94
CV_EXPORTS void add(const Mat &a, double alpha, const Mat &b, double beta, Scalar gamma, Mat &c, int ctype, bool calcAbs=false)
CvSize int int int CvPoint int delta
Definition: core_c.h:1427
RNG rng
Definition: ts.hpp:411
CV_EXPORTS void convert(const Mat &src, Mat &dst, int dtype, double alpha=1, double beta=0)
CvArr int CvScalar param1
Definition: core_c.h:649
const CvMat CvMat CvMat int k
Definition: legacy.hpp:3052
CV_EXPORTS_W int64 getTickCount()
Returns the number of ticks.
GLuint GLuint GLsizei count
Definition: core_c.h:973
struct CvFileStorage CvFileStorage
Definition: types_c.h:1740
Definition: types_c.h:1828
double randReal(RNG &rng)
Definition: ts.hpp:58
int test_case_idx
Definition: ts.hpp:261
double maxdiff
Definition: ts.hpp:174
Definition: types_c.h:645
double const CvArr double beta
Definition: core_c.h:523
unsigned randInt(RNG &rng)
Definition: ts.hpp:53
double t
Definition: ts.hpp:477
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
The n-dimensional matrix class.
Definition: core.hpp:1688
CV_EXPORTS void copyMakeBorder(const Mat &src, Mat &dst, int top, int bottom, int left, int right, int borderType, const Scalar &borderValue=Scalar())
TestInfo current_test_info
Definition: ts.hpp:414
CV_EXPORTS cv::Size randomSize(int minVal, int maxVal)
CV_EXPORTS void minMaxLoc(const Mat &src, double *minval, double *maxval, vector< int > *minloc, vector< int > *maxloc, const Mat &mask=Mat())
CV_EXPORTS void erode(const Mat &src, Mat &dst, const Mat &_kernel, Point anchor=Point(-1,-1), int borderType=IPL_BORDER_CONSTANT, const Scalar &borderValue=Scalar())
vector< vector< void * > > test_array
Definition: ts.hpp:459
CV_EXPORTS void smoothBorder(Mat &img, const Scalar &color, int delta=3)
CV_EXPORTS std::vector< MatType > types(int depth_start, int depth_end, int cn_start, int cn_end)
return vector with types from specified range.
Definition: ts_gtest.h:17733
int context
Definition: ts.hpp:177
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
CV_EXPORTS void extract(const Mat &a, Mat &plane, int coi)
GLenum const GLfloat * params
Definition: compat.hpp:688
CV_EXPORTS void randUni(RNG &rng, Mat &a, const Scalar ¶m1, const Scalar ¶m2)
__int64 int64
Definition: types_c.h:158
CV_EXPORTS void multiply(const Mat &a, const Mat &b, Mat &c, double alpha=1)
const GLubyte * c
Definition: legacy.hpp:633
vector< int > loc0
Definition: ts.hpp:176
bool cvmat_allowed
Definition: ts.hpp:449
CV_EXPORTS void logicOp(const Mat &src1, const Mat &src2, Mat &dst, char c)
CV_EXPORTS void max(const Mat &src1, const Mat &src2, Mat &dst)
CvArr int code
Definition: imgproc_c.h:144
const char * ptr
Definition: core_c.h:942
RNG & get_rng()
Definition: ts.hpp:395
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
const uint64 old_state
Definition: ts.hpp:535
const TestInfo * get_current_test_info()
Definition: ts.hpp:317
CV_EXPORTS std::ostream & operator<<(std::ostream &out, const MatInfo &m)
const CvMat const CvMat * F
Definition: calib3d.hpp:297
CV_EXPORTS int check(const Mat &data, double min_val, double max_val, vector< int > *idx)
CV_EXPORTS void filter2D(const Mat &src, Mat &dst, int ddepth, const Mat &kernel, Point anchor, double delta, int borderType, const Scalar &borderValue=Scalar())
CV_EXPORTS Scalar mean(const Mat &src, const Mat &mask=Mat())
CvArr int CvScalar CvScalar param2
Definition: core_c.h:649
CV_EXPORTS int64 readSeed(const char *str)
CvArr * arr
Definition: core_c.h:649
int get_err_code()
Definition: ts.hpp:398
double const CvArr double double gamma
Definition: core_c.h:523
GLuint dst
Definition: calib3d.hpp:134
The standard OpenCV exception class.
Definition: core.hpp:143
double test_case_count_scale
Definition: ts.hpp:280
CV_EXPORTS void printVersionInfo(bool useStdOut=true)
vector< vector< Mat > > test_mat
Definition: ts.hpp:460
int progress
Definition: ts.hpp:476
CV_EXPORTS void transpose(const Mat &src, Mat &dst)
bool iplimage_allowed
Definition: ts.hpp:450
GLdouble GLdouble GLdouble bottom
const CvArr CvArr CvStereoBMState * state
Definition: calib3d.hpp:353
CV_EXPORTS void initUndistortMap(const Mat &a, const Mat &k, Size sz, Mat &mapx, Mat &mapy)
const void int const char * dt
Definition: core_c.h:1568
int code
error code
Definition: core.hpp:165
CV_EXPORTS void cvTsCopy(const CvMat *a, CvMat *b, const CvMat *mask=0)
GLint GLint GLsizei GLsizei GLsizei depth
Definition: core_c.h:76
unsigned __int64 uint64
Definition: types_c.h:159
const CvArr const CvArr * src2
Definition: core_c.h:436
CV_EXPORTS void cvTsGEMM(const CvMat *a, const CvMat *b, double alpha, const CvMat *c, double beta, CvMat *d, int flags)
CV_EXPORTS double crossCorr(const Mat &src1, const Mat &src2)
TS * ts
Definition: ts.hpp:236
int run_test_case(int expected_code, const string &_descr, F f)
Definition: ts.hpp:480
GLenum GLint GLuint mask
Definition: tracking.hpp:132
MatInfo(const Mat &_m)
Definition: ts.hpp:160
CV_EXPORTS int cmpEps2_64f(TS *ts, const double *val, const double *refval, int len, double eps, const char *param_name)
GLsizeiptr size
Definition: core_c.h:939
int code
Definition: ts.hpp:252
Scalar_< double > Scalar
Definition: core.hpp:968
CV_EXPORTS void compare(const Mat &src1, const Mat &src2, Mat &dst, int cmpop)
string data_path
Definition: ts.hpp:417
Rect_< int > Rect
Definition: core.hpp:897
double double * max_val
Definition: core_c.h:833
short float uchar uchar uchar uchar uchar ushort int uchar ushort int float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float int int int float int int int float int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP char CV_CUDEV_IMPLEMENT_VEC_BINARY_OP ushort CV_CUDEV_IMPLEMENT_VEC_BINARY_OP short CV_CUDEV_IMPLEMENT_VEC_BINARY_OP int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP uint CV_CUDEV_IMPLEMENT_VEC_BINARY_OP float CV_CUDEV_IMPLEMENT_VEC_BINARY_OP double int int uint double
Definition: vec_math.hpp:432
CV_EXPORTS double getMaxVal(int depth)
CV_EXPORTS void insert(const Mat &plane, Mat &a, int coi)
DefaultRngAuto()
Definition: ts.hpp:537
GLuint color
Definition: core_c.h:1276