diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 72c7fc8308..91b65f59aa 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -581,7 +581,7 @@ function(ocv_add_perf_tests) __ocv_parse_test_sources(PERF ${ARGN}) # opencv_highgui is required for imread/imwrite - set(perf_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_PERF_${the_module}_DEPS}) + set(perf_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_PERF_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS}) ocv_check_dependencies(${perf_deps}) if(OCV_DEPENDENCIES_FOUND) @@ -632,7 +632,7 @@ function(ocv_add_accuracy_tests) __ocv_parse_test_sources(TEST ${ARGN}) # opencv_highgui is required for imread/imwrite - set(test_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_TEST_${the_module}_DEPS}) + set(test_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_TEST_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS}) ocv_check_dependencies(${test_deps}) if(OCV_DEPENDENCIES_FOUND) diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt index c50b396faf..455ef876bd 100644 --- a/modules/ts/CMakeLists.txt +++ b/modules/ts/CMakeLists.txt @@ -10,7 +10,8 @@ endif() set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE) -ocv_add_module(ts opencv_core) +ocv_add_module(ts opencv_core opencv_features2d) + ocv_glob_module_sources() ocv_module_include_directories() ocv_create_module() diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 449b434504..81d2235d51 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -2,6 +2,7 @@ #define __OPENCV_TS_PERF_HPP__ #include "opencv2/core/core.hpp" +#include "opencv2/features2d/features2d.hpp" #include "ts_gtest.h" #ifdef HAVE_TBB @@ -165,6 +166,7 @@ class CV_EXPORTS Regression { public: static Regression& add(TestBase* test, const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); + static Regression& addKeypoints(TestBase* test, const std::string& name, const std::vector& array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); static void Init(const std::string& testSuitName, const std::string& ext = ".xml"); Regression& operator() (const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); @@ -199,6 +201,7 @@ private: }; #define SANITY_CHECK(array, ...) ::perf::Regression::add(this, #array, array , ## __VA_ARGS__) +#define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__) /*****************************************************************************************\ diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index a59880afdc..24b91f0185 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -103,6 +103,24 @@ Regression& Regression::add(TestBase* test, const std::string& name, cv::InputAr return instance()(name, array, eps, err); } +Regression& Regression::addKeypoints(TestBase* test, const std::string& name, const std::vector& array, double eps, ERROR_TYPE err) +{ + int len = (int)array.size(); + cv::Mat pt (len, 1, CV_32FC2, (void*)&array[0].pt, sizeof(cv::KeyPoint)); + cv::Mat size (len, 1, CV_32FC1, (void*)&array[0].size, sizeof(cv::KeyPoint)); + cv::Mat angle (len, 1, CV_32FC1, (void*)&array[0].angle, sizeof(cv::KeyPoint)); + cv::Mat response(len, 1, CV_32FC1, (void*)&array[0].response, sizeof(cv::KeyPoint)); + cv::Mat octave (len, 1, CV_32SC1, (void*)&array[0].octave, sizeof(cv::KeyPoint)); + cv::Mat class_id(len, 1, CV_32SC1, (void*)&array[0].class_id, sizeof(cv::KeyPoint)); + + return Regression::add(test, name + "-pt", pt, eps, ERROR_ABSOLUTE) + (name + "-size", size, eps, ERROR_ABSOLUTE) + (name + "-angle", angle, eps, ERROR_ABSOLUTE) + (name + "-response", response, eps, err) + (name + "-octave", octave, eps, ERROR_ABSOLUTE) + (name + "-class_id", class_id, eps, ERROR_ABSOLUTE); +} + void Regression::Init(const std::string& testSuitName, const std::string& ext) { instance().init(testSuitName, ext); @@ -490,6 +508,12 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR Regression& Regression::operator() (const std::string& name, cv::InputArray array, double eps, ERROR_TYPE err) { + if(!array.empty() && array.depth() == CV_USRTYPE1) + { + ADD_FAILURE() << " Can not check regression for CV_USRTYPE1 data type for " << name; + return *this; + } + std::string nodename = getCurrentTestNodeName(); cv::FileNode n = rootIn[nodename];