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:
@@ -40,15 +40,12 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::ml;
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
using cv::ml::SVMSGD;
|
||||
using cv::ml::TrainData;
|
||||
|
||||
|
||||
|
||||
class CV_SVMSGDTrainTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
@@ -300,7 +297,7 @@ TEST(ML_SVMSGD, twoPoints)
|
||||
|
||||
float realShift = -500000.5;
|
||||
|
||||
float normRealWeights = static_cast<float>(norm(realWeights));
|
||||
float normRealWeights = static_cast<float>(cv::norm(realWeights)); // TODO cvtest
|
||||
realWeights /= normRealWeights;
|
||||
realShift /= normRealWeights;
|
||||
|
||||
@@ -311,8 +308,11 @@ TEST(ML_SVMSGD, twoPoints)
|
||||
Mat foundWeights = svmsgd->getWeights();
|
||||
float foundShift = svmsgd->getShift();
|
||||
|
||||
float normFoundWeights = static_cast<float>(norm(foundWeights));
|
||||
float normFoundWeights = static_cast<float>(cv::norm(foundWeights)); // TODO cvtest
|
||||
foundWeights /= normFoundWeights;
|
||||
foundShift /= normFoundWeights;
|
||||
CV_Assert((norm(foundWeights - realWeights) < 0.001) && (abs((foundShift - realShift) / realShift) < 0.05));
|
||||
EXPECT_LE(cv::norm(Mat(foundWeights - realWeights)), 0.001); // TODO cvtest
|
||||
EXPECT_LE(std::abs((foundShift - realShift) / realShift), 0.05);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user