1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

ts: refactor OpenCV tests

- removed tr1 usage (dropped in C++17)
- moved includes of vector/map/iostream/limits into ts.hpp
- require opencv_test + anonymous namespace (added compile check)
- fixed norm() usage (must be from cvtest::norm for checks) and other conflict functions
- added missing license headers
This commit is contained in:
Alexander Alekhin
2017-11-05 13:48:40 +00:00
parent f1e50ecab3
commit 4a297a2443
435 changed files with 2009 additions and 2378 deletions
@@ -48,7 +48,7 @@
#ifdef HAVE_OPENCL
namespace cvtest {
namespace opencv_test {
namespace ocl {
//////////////////// BruteForceMatch /////////////////
@@ -4,7 +4,7 @@
#ifdef HAVE_OPENCL
namespace cvtest {
namespace opencv_test {
namespace ocl {
OCL_PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))
@@ -1,20 +1,18 @@
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test
{
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
CV_ENUM(NormType, NORM_L1, NORM_L2, NORM_L2SQR, NORM_HAMMING, NORM_HAMMING2)
typedef std::tr1::tuple<NormType, MatType, bool> Norm_Destination_CrossCheck_t;
typedef tuple<NormType, MatType, bool> Norm_Destination_CrossCheck_t;
typedef perf::TestBaseWithParam<Norm_Destination_CrossCheck_t> Norm_Destination_CrossCheck;
typedef std::tr1::tuple<NormType, bool> Norm_CrossCheck_t;
typedef tuple<NormType, bool> Norm_CrossCheck_t;
typedef perf::TestBaseWithParam<Norm_CrossCheck_t> Norm_CrossCheck;
typedef std::tr1::tuple<MatType, bool> Source_CrossCheck_t;
typedef tuple<MatType, bool> Source_CrossCheck_t;
typedef perf::TestBaseWithParam<Source_CrossCheck_t> Source_CrossCheck;
void generateData( Mat& query, Mat& train, const int sourceType );
@@ -165,3 +163,5 @@ void generateData( Mat& query, Mat& train, const int sourceType )
}
}
}
} // namespace
@@ -1,5 +1,9 @@
#include "perf_feature2d.hpp"
namespace opencv_test
{
using namespace perf;
PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))
{
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
@@ -64,3 +68,5 @@ PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECT
EXPECT_EQ((size_t)descriptors.rows, points.size());
SANITY_CHECK_NOTHING();
}
} // namespace
+6 -6
View File
@@ -3,13 +3,11 @@
#include "perf_precomp.hpp"
namespace opencv_test
{
/* cofiguration for tests of detectors/descriptors. shared between ocl and cpu tests. */
using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
// detectors/descriptors configurations to test
#define DETECTORS_ONLY \
FAST_DEFAULT, FAST_20_TRUE_TYPE5_8, FAST_20_TRUE_TYPE7_12, FAST_20_TRUE_TYPE9_16, \
@@ -30,7 +28,7 @@ using std::tr1::get;
enum Feature2DVals { DETECTORS_ONLY, DETECTORS_EXTRACTORS };
CV_ENUM_EXPAND(Feature2DType, DETECTORS_ONLY, DETECTORS_EXTRACTORS)
typedef std::tr1::tuple<Feature2DType, string> Feature2DType_String_t;
typedef tuple<Feature2DType, string> Feature2DType_String_t;
typedef perf::TestBaseWithParam<Feature2DType_String_t> feature2d;
#define TEST_IMAGES testing::Values(\
@@ -84,4 +82,6 @@ static inline Ptr<Feature2D> getFeature2D(Feature2DType type)
}
}
} // namespace
#endif // __OPENCV_PERF_FEATURE2D_HPP__
-13
View File
@@ -1,20 +1,7 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
#endif
#ifndef __OPENCV_PERF_PRECOMP_HPP__
#define __OPENCV_PERF_PRECOMP_HPP__
#include "opencv2/ts.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/features2d.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif
#endif
@@ -54,7 +54,7 @@
#ifdef HAVE_OPENCL
namespace cvtest {
namespace opencv_test {
namespace ocl {
PARAM_TEST_CASE(BruteForceMatcher, int, int)
{
@@ -8,7 +8,7 @@
#ifdef HAVE_OPENCL
namespace cvtest {
namespace opencv_test {
namespace ocl {
#define TEST_IMAGES testing::Values(\
+3 -2
View File
@@ -42,8 +42,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
class CV_AgastTest : public cvtest::BaseTest
{
@@ -135,3 +134,5 @@ void CV_AgastTest::run( int )
}
TEST(Features2d_AGAST, regression) { CV_AgastTest test; test.safe_run(); }
}} // namespace
+3 -2
View File
@@ -4,8 +4,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
TEST(Features2d_AKAZE, detect_and_compute_split)
{
@@ -45,3 +44,5 @@ TEST(Features2d_AKAZE, uninitialized_and_nans)
Ptr<Feature2D> akaze = AKAZE::create();
akaze->detectAndCompute(b1, noArray(), keypoints, desc);
}
}} // namespace
+3 -2
View File
@@ -42,8 +42,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
class CV_BRISKTest : public cvtest::BaseTest
{
@@ -93,3 +92,5 @@ void CV_BRISKTest::run( int )
}
TEST(Features2d_BRISK, regression) { CV_BRISKTest test; test.safe_run(); }
}} // namespace
@@ -5,15 +5,11 @@
#include "test_precomp.hpp"
#include "test_invariance_utils.hpp"
using namespace std;
using namespace cv;
using std::tr1::make_tuple;
using std::tr1::get;
using namespace testing;
namespace opencv_test { namespace {
#define SHOW_DEBUG_LOG 1
typedef std::tr1::tuple<std::string, Ptr<FeatureDetector>, Ptr<DescriptorExtractor>, float>
typedef tuple<std::string, Ptr<FeatureDetector>, Ptr<DescriptorExtractor>, float>
String_FeatureDetector_DescriptorExtractor_Float_t;
const static std::string IMAGE_TSUKUBA = "features2d/tsukuba.png";
const static std::string IMAGE_BIKES = "detectors_descriptors_evaluation/images_datasets/bikes/img1.png";
@@ -192,3 +188,5 @@ INSTANTIATE_TEST_CASE_P(AKAZE, DescriptorScaleInvariance,
INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, DescriptorScaleInvariance,
Value(IMAGE_BIKES, AKAZE::create(AKAZE::DESCRIPTOR_KAZE), AKAZE::create(AKAZE::DESCRIPTOR_KAZE), 0.55f));
}} // namespace
@@ -41,9 +41,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
using namespace testing;
namespace opencv_test { namespace {
const string FEATURES2D_DIR = "features2d";
const string IMAGE_FILENAME = "tsukuba.png";
@@ -151,7 +149,7 @@ protected:
float exact_percents = (100 * (float)exact_count / validDescriptors.rows);
float failed_percents = (100 * (float)failed_count / validDescriptors.rows);
stringstream ss;
std::stringstream ss;
ss << "Exact count (dist == 0): " << exact_count << " (" << (int)exact_percents << "%)" << std::endl
<< "Failed count (dist > " << maxDist << "): " << failed_count << " (" << (int)failed_percents << "%)" << std::endl
<< "Max distance between valid and computed descriptors (" << validDescriptors.size() << "): " << curMaxDist;
@@ -497,3 +495,5 @@ INSTANTIATE_TEST_CASE_P(Features2d, DescriptorImage,
"shared/templ.png"
)
);
}} // namespace
@@ -5,15 +5,12 @@
#include "test_precomp.hpp"
#include "test_invariance_utils.hpp"
using namespace std;
using namespace cv;
using std::tr1::make_tuple;
using std::tr1::get;
using namespace testing;
namespace opencv_test { namespace {
using namespace perf;
#define SHOW_DEBUG_LOG 1
typedef std::tr1::tuple<std::string, Ptr<FeatureDetector>, float, float> String_FeatureDetector_Float_Float_t;
typedef tuple<std::string, Ptr<FeatureDetector>, float, float> String_FeatureDetector_Float_Float_t;
const static std::string IMAGE_TSUKUBA = "features2d/tsukuba.png";
const static std::string IMAGE_BIKES = "detectors_descriptors_evaluation/images_datasets/bikes/img1.png";
#define Value(...) Values(String_FeatureDetector_Float_Float_t(__VA_ARGS__))
@@ -253,3 +250,5 @@ INSTANTIATE_TEST_CASE_P(AKAZE, DetectorScaleInvariance,
INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, DetectorScaleInvariance,
Value(IMAGE_BIKES, AKAZE::create(AKAZE::DESCRIPTOR_KAZE), 0.08f, 0.49f));
}} // namespace
@@ -41,8 +41,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
const string FEATURES2D_DIR = "features2d";
const string IMAGE_FILENAME = "tsukuba.png";
@@ -114,7 +113,7 @@ bool CV_FeatureDetectorTest::isSimilarKeypoints( const KeyPoint& p1, const KeyPo
const float maxAngleDif = 2.f;
const float maxResponseDif = 0.1f;
float dist = (float)norm( p1.pt - p2.pt );
float dist = (float)cv::norm( p1.pt - p2.pt );
return (dist < maxPtDif &&
fabs(p1.size - p2.size) < maxSizeDif &&
abs(p1.angle - p2.angle) < maxAngleDif &&
@@ -147,7 +146,7 @@ void CV_FeatureDetectorTest::compareKeypointSets( const vector<KeyPoint>& validK
for( size_t c = 0; c < calcKeypoints.size(); c++ )
{
progress = update_progress( progress, (int)(v*calcKeypoints.size() + c), progressCount, 0 );
float curDist = (float)norm( calcKeypoints[c].pt - validKeypoints[v].pt );
float curDist = (float)cv::norm( calcKeypoints[c].pt - validKeypoints[v].pt );
if( curDist < minDist )
{
minDist = curDist;
@@ -307,3 +306,5 @@ TEST( Features2d_Detector_AKAZE_DESCRIPTOR_KAZE, regression )
CV_FeatureDetectorTest test( "detector-akaze-with-kaze-desc", AKAZE::create(AKAZE::DESCRIPTOR_KAZE) );
test.safe_run();
}
}} // namespace
+3 -2
View File
@@ -42,8 +42,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
class CV_FastTest : public cvtest::BaseTest
{
@@ -135,3 +134,5 @@ void CV_FastTest::run( int )
}
TEST(Features2d_FAST, regression) { CV_FastTest test; test.safe_run(); }
}} // namespace
@@ -5,12 +5,8 @@
#ifndef __OPENCV_TEST_INVARIANCE_UTILS_HPP__
#define __OPENCV_TEST_INVARIANCE_UTILS_HPP__
#include "test_precomp.hpp"
namespace opencv_test { namespace {
using namespace std;
using namespace cv;
static
Mat generateHomography(float angle)
{
// angle - rotation around Oz in degrees
@@ -23,7 +19,6 @@ Mat generateHomography(float angle)
return H;
}
static
Mat rotateImage(const Mat& srcImage, const Mat& srcMask, float angle, Mat& dstImage, Mat& dstMask)
{
// angle - rotation around Oz in degrees
@@ -43,10 +38,9 @@ Mat rotateImage(const Mat& srcImage, const Mat& srcMask, float angle, Mat& dstIm
return H;
}
static
float calcCirclesIntersectArea(const Point2f& p0, float r0, const Point2f& p1, float r1)
{
float c = static_cast<float>(norm(p0 - p1)), sqr_c = c * c;
float c = static_cast<float>(cv::norm(p0 - p1)), sqr_c = c * c;
float sqr_r0 = r0 * r0;
float sqr_r1 = r1 * r1;
@@ -69,7 +63,6 @@ float calcCirclesIntersectArea(const Point2f& p0, float r0, const Point2f& p1, f
0.5f * sqr_r1 * (A1 - sin(A1));
}
static
float calcIntersectRatio(const Point2f& p0, float r0, const Point2f& p1, float r1)
{
float intersectArea = calcCirclesIntersectArea(p0, r0, p1, r1);
@@ -77,7 +70,6 @@ float calcIntersectRatio(const Point2f& p0, float r0, const Point2f& p1, float r
return intersectArea / unionArea;
}
static
void scaleKeyPoints(const vector<KeyPoint>& src, vector<KeyPoint>& dst, float scale)
{
dst.resize(src.size());
@@ -89,4 +81,5 @@ void scaleKeyPoints(const vector<KeyPoint>& src, vector<KeyPoint>& dst, float sc
}
}
}} // namespace
#endif // __OPENCV_TEST_INVARIANCE_UTILS_HPP__
+3 -2
View File
@@ -42,8 +42,7 @@
#include "test_precomp.hpp"
#include "opencv2/core/core_c.h"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
const string FEATURES2D_DIR = "features2d";
const string IMAGE_FILENAME = "tsukuba.png";
@@ -177,3 +176,5 @@ TEST(Features2d_Detector_Keypoints_AKAZE, validation)
CV_FeatureDetectorKeypointsTest test_mldb(AKAZE::create(AKAZE::DESCRIPTOR_MLDB));
test_mldb.safe_run();
}
}} // namespace
+3
View File
@@ -1,3 +1,6 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
CV_TEST_MAIN("cv")
@@ -41,8 +41,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
const string FEATURES2D_DIR = "features2d";
const string IMAGE_FILENAME = "tsukuba.png";
@@ -65,7 +64,9 @@ protected:
virtual void run( int );
void generateData( Mat& query, Mat& train );
void emptyDataTest();
#if 0
void emptyDataTest(); // FIXIT not used
#endif
void matchTest( const Mat& query, const Mat& train );
void knnMatchTest( const Mat& query, const Mat& train );
void radiusMatchTest( const Mat& query, const Mat& train );
@@ -77,6 +78,7 @@ private:
CV_DescriptorMatcherTest& operator=(const CV_DescriptorMatcherTest&) { return *this; }
};
#if 0
void CV_DescriptorMatcherTest::emptyDataTest()
{
assert( !dmatcher.empty() );
@@ -156,6 +158,7 @@ void CV_DescriptorMatcherTest::emptyDataTest()
}
}
#endif
void CV_DescriptorMatcherTest::generateData( Mat& query, Mat& train )
{
@@ -554,3 +557,5 @@ TEST( Features2d_DMatch, read_write )
String str = fs.releaseAndGetString();
ASSERT_NE( strstr(str.c_str(), "4.5"), (char*)0 );
}
}} // namespace
+4 -6
View File
@@ -41,12 +41,8 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/highgui.hpp"
#include <vector>
#include <string>
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
#undef RENDER_MSERS
#define RENDER_MSERS 0
@@ -127,7 +123,7 @@ TEST(Features2d_MSER, cases)
if( invert )
bitwise_not(src, src);
if( binarize )
threshold(src, src, thresh, 255, THRESH_BINARY);
cv::threshold(src, src, thresh, 255, THRESH_BINARY);
if( blur )
GaussianBlur(src, src, Size(5, 5), 1.5, 1.5);
@@ -182,3 +178,5 @@ TEST(Features2d_MSER, history_update_regression)
}
}
}
}} // namespace
@@ -43,12 +43,8 @@
#include "test_precomp.hpp"
#include <algorithm>
#include <vector>
#include <iostream>
namespace opencv_test { namespace {
using namespace std;
using namespace cv;
#ifdef HAVE_OPENCV_FLANN
using namespace cv::flann;
#endif
@@ -337,3 +333,5 @@ TEST(Features2d_FLANN_Auto, regression) { CV_FlannAutotunedIndexTest test; test.
TEST(Features2d_FLANN_Saved, regression) { CV_FlannSavedIndexTest test; test.safe_run(); }
#endif
}} // namespace
+3 -2
View File
@@ -41,8 +41,7 @@
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
namespace opencv_test { namespace {
TEST(Features2D_ORB, _1996)
{
@@ -123,3 +122,5 @@ TEST(Features2D_ORB, crash)
ASSERT_NO_THROW(orb->compute(image, keypoints, descriptors));
}
}} // namespace
+3 -11
View File
@@ -1,18 +1,10 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
#endif
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#include "opencv2/ts.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/imgcodecs.hpp"
#include <iostream>
#endif