43 #ifndef __OPENCV_GPU_TEST_UTILITY_HPP__
44 #define __OPENCV_GPU_TEST_UTILITY_HPP__
58 CV_EXPORTS
int randomInt(
int minVal,
int maxVal);
59 CV_EXPORTS
double randomDouble(
double minVal,
double maxVal);
93 const std::vector<cv::gpu::DeviceInfo>&
values()
const {
return devices_; }
96 std::vector<cv::gpu::DeviceInfo> devices_;
99 #define ALL_DEVICES testing::ValuesIn(cvtest::DeviceManager::instance().values())
110 #define EXPECT_MAT_NEAR(m1, m2, eps) EXPECT_PRED_FORMAT3(cvtest::assertMatNear, m1, m2, eps)
111 #define ASSERT_MAT_NEAR(m1, m2, eps) ASSERT_PRED_FORMAT3(cvtest::assertMatNear, m1, m2, eps)
113 #define EXPECT_SCALAR_NEAR(s1, s2, eps) \
115 EXPECT_NEAR(s1[0], s2[0], eps); \
116 EXPECT_NEAR(s1[1], s2[1], eps); \
117 EXPECT_NEAR(s1[2], s2[2], eps); \
118 EXPECT_NEAR(s1[3], s2[3], eps); \
120 #define ASSERT_SCALAR_NEAR(s1, s2, eps) \
122 ASSERT_NEAR(s1[0], s2[0], eps); \
123 ASSERT_NEAR(s1[1], s2[1], eps); \
124 ASSERT_NEAR(s1[2], s2[2], eps); \
125 ASSERT_NEAR(s1[3], s2[3], eps); \
128 #define EXPECT_POINT2_NEAR(p1, p2, eps) \
130 EXPECT_NEAR(p1.x, p2.x, eps); \
131 EXPECT_NEAR(p1.y, p2.y, eps); \
133 #define ASSERT_POINT2_NEAR(p1, p2, eps) \
135 ASSERT_NEAR(p1.x, p2.x, eps); \
136 ASSERT_NEAR(p1.y, p2.y, eps); \
139 #define EXPECT_POINT3_NEAR(p1, p2, eps) \
141 EXPECT_NEAR(p1.x, p2.x, eps); \
142 EXPECT_NEAR(p1.y, p2.y, eps); \
143 EXPECT_NEAR(p1.z, p2.z, eps); \
145 #define ASSERT_POINT3_NEAR(p1, p2, eps) \
147 ASSERT_NEAR(p1.x, p2.x, eps); \
148 ASSERT_NEAR(p1.y, p2.y, eps); \
149 ASSERT_NEAR(p1.z, p2.z, eps); \
154 #define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
156 ASSERT_EQ(mat1.type(), mat2.type()); \
157 ASSERT_EQ(mat1.size(), mat2.size()); \
158 EXPECT_LE(checkSimilarity(mat1, mat2), eps); \
160 #define ASSERT_MAT_SIMILAR(mat1, mat2, eps) \
162 ASSERT_EQ(mat1.type(), mat2.type()); \
163 ASSERT_EQ(mat1.size(), mat2.size()); \
164 ASSERT_LE(checkSimilarity(mat1, mat2), eps); \
170 #define GPU_TEST_P(test_case_name, test_name) \
171 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
172 : public test_case_name { \
174 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
175 virtual void TestBody(); \
177 void UnsafeTestBody(); \
178 static int AddToRegistry() { \
179 ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
180 GetTestCasePatternHolder<test_case_name>(\
181 #test_case_name, __FILE__, __LINE__)->AddTestPattern(\
184 new ::testing::internal::TestMetaFactory< \
185 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
188 static int gtest_registering_dummy_; \
189 GTEST_DISALLOW_COPY_AND_ASSIGN_(\
190 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
192 int GTEST_TEST_CLASS_NAME_(test_case_name, \
193 test_name)::gtest_registering_dummy_ = \
194 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
195 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() \
203 cv::gpu::resetDevice(); \
207 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::UnsafeTestBody()
209 #define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
210 #define GET_PARAM(k) std::tr1::get< k >(GetParam())
212 #define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113))
216 using perf::MatDepth;
218 #define ALL_DEPTH testing::Values(MatDepth(CV_8U), MatDepth(CV_8S), MatDepth(CV_16U), MatDepth(CV_16S), MatDepth(CV_32S), MatDepth(CV_32F), MatDepth(CV_64F))
220 #define DEPTH_PAIRS testing::Values(std::make_pair(MatDepth(CV_8U), MatDepth(CV_8U)), \
221 std::make_pair(MatDepth(CV_8U), MatDepth(CV_16U)), \
222 std::make_pair(MatDepth(CV_8U), MatDepth(CV_16S)), \
223 std::make_pair(MatDepth(CV_8U), MatDepth(CV_32S)), \
224 std::make_pair(MatDepth(CV_8U), MatDepth(CV_32F)), \
225 std::make_pair(MatDepth(CV_8U), MatDepth(CV_64F)), \
227 std::make_pair(MatDepth(CV_16U), MatDepth(CV_16U)), \
228 std::make_pair(MatDepth(CV_16U), MatDepth(CV_32S)), \
229 std::make_pair(MatDepth(CV_16U), MatDepth(CV_32F)), \
230 std::make_pair(MatDepth(CV_16U), MatDepth(CV_64F)), \
232 std::make_pair(MatDepth(CV_16S), MatDepth(CV_16S)), \
233 std::make_pair(MatDepth(CV_16S), MatDepth(CV_32S)), \
234 std::make_pair(MatDepth(CV_16S), MatDepth(CV_32F)), \
235 std::make_pair(MatDepth(CV_16S), MatDepth(CV_64F)), \
237 std::make_pair(MatDepth(CV_32S), MatDepth(CV_32S)), \
238 std::make_pair(MatDepth(CV_32S), MatDepth(CV_32F)), \
239 std::make_pair(MatDepth(CV_32S), MatDepth(CV_64F)), \
241 std::make_pair(MatDepth(CV_32F), MatDepth(CV_32F)), \
242 std::make_pair(MatDepth(CV_32F), MatDepth(CV_64F)), \
244 std::make_pair(MatDepth(CV_64F), MatDepth(CV_64F)))
251 CV_EXPORTS std::vector<MatType>
types(
int depth_start,
int depth_end,
int cn_start,
int cn_end);
254 CV_EXPORTS
const std::vector<MatType>&
all_types();
256 #define ALL_TYPES testing::ValuesIn(all_types())
257 #define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end))
266 inline operator bool()
const {
return val_; }
272 CV_EXPORTS
void PrintTo(
const UseRoi& useRoi, std::ostream* os);
274 #define WHOLE_SUBMAT testing::Values(UseRoi(false), UseRoi(true))
283 inline operator bool()
const {
return val_; }
289 CV_EXPORTS
void PrintTo(
const Inverse& useRoi, std::ostream* os);
291 #define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
295 #define IMPLEMENT_PARAM_CLASS(name, type) \
299 name ( type arg = type ()) : val_(arg) {} \
300 operator type () const {return val_;} \
304 inline void PrintTo( name param, std::ostream* os) \
306 *os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \
311 #define ALL_CHANNELS testing::Values(Channels(1), Channels(2), Channels(3), Channels(4))
312 #define IMAGE_CHANNELS testing::Values(Channels(1), Channels(3), Channels(4))
321 #define ALL_BORDER_TYPES testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_CONSTANT), BorderType(cv::BORDER_REFLECT), BorderType(cv::BORDER_WRAP))
323 CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC,
WARP_INVERSE_MAP)
328 CV_EXPORTS testing::AssertionResult assertKeyPointsEquals(const
char* gold_expr, const
char* actual_expr, std::vector<cv::KeyPoint>& gold, std::vector<cv::KeyPoint>& actual);
330 #define ASSERT_KEYPOINTS_EQ(gold, actual) EXPECT_PRED_FORMAT2(assertKeyPointsEquals, gold, actual)
332 CV_EXPORTS
int getMatchedPointsCount(std::vector<cv::KeyPoint>& gold, std::vector<cv::KeyPoint>& actual);
333 CV_EXPORTS
int getMatchedPointsCount(
const std::vector<cv::KeyPoint>& keypoints1,
const std::vector<cv::KeyPoint>& keypoints2,
const std::vector<cv::DMatch>& matches);
344 namespace cv {
namespace gpu
346 CV_EXPORTS
void PrintTo(
const DeviceInfo& info, std::ostream* os);
349 #endif // __OPENCV_GPU_TEST_UTILITY_HPP__
NORM_MINMAX CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA) CV_ENUM(BorderType
NORM_MINMAX BORDER_REPLICATE
Definition: gpu_test.hpp:320
CV_EXPORTS cv::gpu::GpuMat createMat(cv::Size size, int type, bool useRoi=false)
area-based (or super) interpolation
Definition: imgproc.hpp:557
bicubic interpolation
Definition: imgproc.hpp:556
CV_EXPORTS int getMatchedPointsCount(std::vector< cv::KeyPoint > &gold, std::vector< cv::KeyPoint > &actual)
NORM_TYPE_MASK
Definition: gpu_test.hpp:316
CV_EXPORTS void printCudaInfo()
CV_EXPORTS bool supportFeature(const cv::gpu::DeviceInfo &info, cv::gpu::FeatureSet feature)
return true if device supports specified feature and gpu module was built with support the feature...
NORM_MINMAX BORDER_REFLECT101
Definition: gpu_test.hpp:320
CV_EXPORTS double randomDouble(double minVal, double maxVal)
GLuint src
Definition: core_c.h:1650
IMPLEMENT_PARAM_CLASS(Channels, int) CV_ENUM(NormCode
int int int flags
Definition: highgui_c.h:186
Definition: highgui.hpp:169
NORM_RELATIVE
Definition: gpu_test.hpp:316
int CvMemStorage int double eps
Definition: imgproc_c.h:353
CV_EXPORTS cv::Mat readImage(const std::string &fileName, int flags=cv::IMREAD_COLOR)
read image from testdata folder
Definition: gpu_test.hpp:85
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: highgui_c.h:230
NORM_MINMAX BORDER_REFLECT
Definition: gpu_test.hpp:320
The 2D size class.
Definition: core.hpp:81
CV_EXPORTS double checkSimilarity(cv::InputArray m1, cv::InputArray m2)
CV_EXPORTS cv::Mat randomMat(cv::Size size, int type, double minVal=0.0, double maxVal=255.0)
CV_EXPORTS cv::Mat readImageType(const std::string &fname, int type)
read image from testdata folder and convert it to specified type
SourceFileRef load(const DataSourceRef &dataSource, size_t sampleRate=0)
FeatureSet
Definition: gpumat.hpp:67
CV_EXPORTS int randomInt(int minVal, int maxVal)
Definition: gpumat.hpp:106
Inverse(bool val=false)
Definition: gpu_test.hpp:281
NORM_L1
Definition: gpu_test.hpp:316
Definition: imgproc.hpp:63
CV_EXPORTS testing::AssertionResult assertMatNear(const char *expr1, const char *expr2, const char *eps_expr, cv::InputArray m1, cv::InputArray m2, double eps)
const std::vector< cv::gpu::DeviceInfo > & values() const
Definition: gpu_test.hpp:93
Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat...
Definition: gpumat.hpp:154
Definition: gpu_test.hpp:261
CV_EXPORTS void minMaxLocGold(const cv::Mat &src, double *minVal_, double *maxVal_=0, cv::Point *minLoc_=0, cv::Point *maxLoc_=0, const cv::Mat &mask=cv::Mat())
The n-dimensional matrix class.
Definition: core.hpp:1688
CV_EXPORTS cv::Size randomSize(int minVal, int maxVal)
CV_EXPORTS void PrintTo(const UseRoi &useRoi, std::ostream *os)
CV_EXPORTS void dumpImage(const std::string &fileName, const cv::Mat &image)
CV_EXPORTS void showDiff(cv::InputArray gold, cv::InputArray actual, double eps)
bilinear interpolation
Definition: imgproc.hpp:555
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
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
NORM_MINMAX BORDER_CONSTANT
Definition: gpu_test.hpp:320
Definition: ts_perf.hpp:85
template 2D point class.
Definition: core.hpp:82
Definition: gpu_test.hpp:278
CV_EXPORTS cv::Mat getMat(cv::InputArray arr)
UseRoi(bool val=false)
Definition: gpu_test.hpp:264
CvArr * arr
Definition: core_c.h:649
CV_EXPORTS const std::vector< MatType > & all_types()
return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).
CV_EXPORTS void PrintTo(const DeviceInfo &info, std::ostream *os)
NORM_L2
Definition: gpu_test.hpp:316
nearest neighbor interpolation
Definition: imgproc.hpp:554
Definition: imgproc.hpp:560
GLenum GLint GLuint mask
Definition: tracking.hpp:132
GLsizeiptr size
Definition: core_c.h:939
NORM_INF
Definition: gpu_test.hpp:316
CV_EXPORTS cv::gpu::GpuMat loadMat(const cv::Mat &m, bool useRoi=false)
CV_EXPORTS cv::Scalar randomScalar(double minVal, double maxVal)