diff --git a/modules/dnn/perf/perf_layer.cpp b/modules/dnn/perf/perf_layer.cpp index f70472d89a..bb5d37511e 100644 --- a/modules/dnn/perf/perf_layer.cpp +++ b/modules/dnn/perf/perf_layer.cpp @@ -480,151 +480,6 @@ PERF_TEST_P_(Layer_LayerNorm, LayerNorm_Large) test_layer({1, 512, 768}); } -struct Layer_LayerNormExpanded : public TestBaseWithParam > -{ - void test_layer(const std::vector& x_shape) - { - int backendId = get<0>(GetParam()); - int targetId = get<1>(GetParam()); - - Mat x(x_shape, CV_32FC1); - Mat scale(1, x_shape.back(), CV_32FC1); // transpose to pass shape check - Mat b(1, x_shape.back(), CV_32FC1); // transpose to pass shape check - - randu(x, 0.f, 1.f); - randu(scale, 0.f, 1.f); - randu(b, 0.f, 1.f); - - // sub graph structure: - // -> ReduceMean -> -> Pow(2) -> ReduceMean -> Add(epsilon) -> Sqrt -> - // x Sub Div -> Mul(scale) -> Add(bias) - // ---------------> -------------------------------------------------> - - Net net; - - LayerParams lp_rm; - lp_rm.type = "Reduce"; - lp_rm.name = "reducemean1"; - lp_rm.set("reduce", "AVE"); - std::vector deleteDims(1, x_shape.back()); - lp_rm.set("deleted_dims", DictValue::arrayInt(&deleteDims[0], deleteDims.size())); - std::vector targetDims(x_shape.begin(), x_shape.end()); - targetDims[x_shape.size() - 1] = 1; - lp_rm.set("target_dims", DictValue::arrayInt(&targetDims[0], targetDims.size())); - int id_rm = net.addLayerToPrev(lp_rm.name, lp_rm.type, lp_rm); - net.connect(0, 0, id_rm, 0); - - LayerParams lp_sub; - lp_sub.type = "NaryEltwise"; - lp_sub.name = "sub1"; - lp_sub.set("operation", "sub"); - int id_sub = net.addLayer(lp_sub.name, lp_sub.type, lp_sub); - net.connect(0, 0, id_sub, 0); - net.connect(id_rm, 0, id_sub, 1); - - Mat pow_const(1, 1, CV_32FC1); - pow_const.at(0) = 2.f; - LayerParams lp_pow_const; - lp_pow_const.type = "Const"; - lp_pow_const.name = "const1"; - lp_pow_const.blobs.push_back(pow_const); - int id_pow_const = net.addLayer(lp_pow_const.name, lp_pow_const.type, lp_pow_const); - LayerParams lp_pow; - lp_pow.type = "NaryEltwise"; - lp_pow.name = "pow1"; - lp_pow.set("operation", "pow"); - int id_pow = net.addLayer(lp_pow.name, lp_pow.type, lp_pow); - net.connect(id_sub, 0, id_pow, 0); - net.connect(id_pow_const, 0, id_pow, 1); - - LayerParams lp_rm1; - lp_rm1.type = "Reduce"; - lp_rm1.name = "reducemean2"; - lp_rm1.set("reduce", "AVE"); - lp_rm1.set("deleted_dims", DictValue::arrayInt(&deleteDims[0], deleteDims.size())); - lp_rm1.set("target_dims", DictValue::arrayInt(&targetDims[0], targetDims.size())); - int id_rm1 = net.addLayer(lp_rm1.name, lp_rm1.type, lp_rm1); - net.connect(id_pow, 0, id_rm1, 0); - - Mat add_const(1, 1, CV_32F); - add_const.at(0) = 1e-5; - LayerParams lp_add_const; - lp_add_const.type = "Const"; - lp_add_const.name = "const2"; - lp_add_const.blobs.push_back(add_const); - int id_add_const = net.addLayer(lp_add_const.name, lp_add_const.type, lp_add_const); - LayerParams lp_add; - lp_add.type = "NaryEltwise"; - lp_add.name = "add1"; - lp_add.set("operation", "add"); - int id_add = net.addLayer(lp_add.name, lp_add.type, lp_add); - net.connect(id_rm1, 0, id_add, 0); - net.connect(id_add_const, 0, id_add, 1); - - LayerParams lp_sqrt; - lp_sqrt.type = "Sqrt"; - lp_sqrt.name = "sqrt1"; - int id_sqrt = net.addLayer(lp_sqrt.name, lp_sqrt.type, lp_sqrt); - net.connect(id_add, 0, id_sqrt, 0); - - LayerParams lp_div; - lp_div.type = "NaryEltwise"; - lp_div.name = "div1"; - lp_div.set("operation", "div"); - int id_div = net.addLayer(lp_div.name, lp_div.type, lp_div); - net.connect(id_sub, 0, id_div, 0); - net.connect(id_sqrt, 0, id_div, 1); - - LayerParams lp_mul; - lp_mul.type = "NaryEltwise"; - lp_mul.name = "mul1"; - lp_mul.set("operation", "mul"); - int id_mul = net.addLayer(lp_mul.name, lp_mul.type, lp_mul); - net.connect(id_div, 0, id_mul, 0); - net.connect(0, 1, id_mul, 1); - - LayerParams lp_add1; - lp_add1.type = "NaryEltwise"; - lp_add1.name = "add2"; - lp_add1.set("operation", "add"); - int id_add1 = net.addLayer(lp_add1.name, lp_add1.type, lp_add1); - net.connect(id_mul, 0, id_add1, 0); - net.connect(0, 2, id_add1, 1); - - // warmup - { - std::vector inpNames(3); - inpNames[0] = "x"; - inpNames[1] = "scale"; - inpNames[2] = "b"; - net.setInputsNames(inpNames); - net.setInput(x, inpNames[0]); - net.setInput(scale, inpNames[1]); - net.setInput(b, inpNames[2]); - - net.setPreferableBackend(backendId); - net.setPreferableTarget(targetId); - Mat out = net.forward(); - } - - TEST_CYCLE() - { - Mat res = net.forward(); - } - - SANITY_CHECK_NOTHING(); - } - - int N = 1; - int H = 50; - int W = 768; -}; - -PERF_TEST_P_(Layer_LayerNormExpanded, DISABLED_LayerNormExpanded) -{ - test_layer({N, H ,W}); -} - struct Layer_GatherElements : public TestBaseWithParam > { void test_layer(const std::vector& data_shape, const std::vector& indices_shape, int axis = 0) @@ -1138,7 +993,6 @@ INSTANTIATE_TEST_CASE_P(CUDA, Layer_NaryEltwise, testing::Values(std::make_tuple INSTANTIATE_TEST_CASE_P(VULKAN, Layer_NaryEltwise, testing::Values(std::make_tuple(DNN_BACKEND_VKCOM, DNN_TARGET_VULKAN))); #endif INSTANTIATE_TEST_CASE_P(/**/, Layer_LayerNorm, testing::Values(std::make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU))); -INSTANTIATE_TEST_CASE_P(/**/, Layer_LayerNormExpanded, testing::Values(std::make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU))); INSTANTIATE_TEST_CASE_P(/**/, Layer_GatherElements, testing::Values(std::make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU))); INSTANTIATE_TEST_CASE_P(/**/, Layer_InstanceNorm, testing::Values(std::make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU))); INSTANTIATE_TEST_CASE_P(/**/, Layer_Attention, testing::Values(std::make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU))); diff --git a/modules/geometry/perf/perf_pnp.cpp b/modules/geometry/perf/perf_pnp.cpp index 302d364601..3a700278a5 100644 --- a/modules/geometry/perf/perf_pnp.cpp +++ b/modules/geometry/perf/perf_pnp.cpp @@ -112,19 +112,15 @@ PERF_TEST_P(PointsNum_Algo, solvePnPSmallPoints, SANITY_CHECK(tvec, 1e-2); } -PERF_TEST_P(PointsNum, DISABLED_SolvePnPRansac, testing::Values(5, 3*9, 7*13)) +PERF_TEST_P(PointsNum, SolvePnPRansac, testing::Values(5, 3*9, 7*13)) { int count = GetParam(); Mat object(1, count, CV_32FC3); randu(object, -100, 100); - Mat camera_mat(3, 3, CV_32FC1); - randu(camera_mat, 0.5, 1); - camera_mat.at(0, 1) = 0.f; - camera_mat.at(1, 0) = 0.f; - camera_mat.at(2, 0) = 0.f; - camera_mat.at(2, 1) = 0.f; + // same camera as solvePnP above; a random one with a focal length below 1 px lets any pose pass the RANSAC threshold + Mat camera_mat = Mat_({3, 3}, {400.f, 0.f, 320.f, 0.f, 400.f, 240.f, 0.f, 0.f, 1.f}); Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); @@ -135,20 +131,29 @@ PERF_TEST_P(PointsNum, DISABLED_SolvePnPRansac, testing::Values(5, 3*9, 7*13)) Mat tvec_gold(1, 3, CV_32FC1); randu(tvec_gold, 0, 1); + tvec_gold.at(2) += 500.f; // keep the whole object in front of the camera projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec); Mat image(1, count, CV_32FC2, &image_vec[0]); Mat rvec; Mat tvec; + bool found = false; TEST_CYCLE() { - cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + found = cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); } - SANITY_CHECK(rvec, 1e-6); - SANITY_CHECK(tvec, 1e-6); + // the projections are noise free, so RANSAC must find the generating pose again + EXPECT_TRUE(found); + Mat rvec_gold64, tvec_gold64; + rvec_gold.reshape(1, 3).convertTo(rvec_gold64, CV_64F); + tvec_gold.reshape(1, 3).convertTo(tvec_gold64, CV_64F); + EXPECT_LE(cv::norm(rvec, rvec_gold64, NORM_INF), 1e-4); + EXPECT_LE(cv::norm(tvec, tvec_gold64, NORM_INF), 1e-2); + + SANITY_CHECK_NOTHING(); } } // namespace diff --git a/modules/geometry/perf/perf_undistort.cpp b/modules/geometry/perf/perf_undistort.cpp index fa0d7ea2ec..b8cdc5ce8d 100644 --- a/modules/geometry/perf/perf_undistort.cpp +++ b/modules/geometry/perf/perf_undistort.cpp @@ -16,7 +16,7 @@ PERF_TEST(Undistort, InitUndistortMap) SANITY_CHECK_NOTHING(); } -PERF_TEST(Undistort, DISABLED_InitInverseRectificationMap) +PERF_TEST(Undistort, InitInverseRectificationMap) { Size size_w_h(512 + 3, 512); Mat k(3, 3, CV_32FC1); diff --git a/modules/imgcodecs/perf/perf_decode_encode.cpp b/modules/imgcodecs/perf/perf_decode_encode.cpp index 401f0a3a47..458a53e051 100644 --- a/modules/imgcodecs/perf/perf_decode_encode.cpp +++ b/modules/imgcodecs/perf/perf_decode_encode.cpp @@ -209,10 +209,10 @@ PERF_TEST_P(Encode, multi, testing::ValuesIn(exts_multi)) vec.push_back(vec.back().clone()); circle(vec.back(), Point(100, 100), 45, Scalar(0, 0, 255, 0), 2, LINE_AA); vector buf; - EXPECT_TRUE(imwrite("test" + GetParam(), vec)); TEST_CYCLE() imencode(GetParam(), vec, buf); + EXPECT_FALSE(buf.empty()); std::cout << " Encoded buffer size: " << buf.size() << " bytes, Compression ratio: " << std::fixed << std::setprecision(2) << (static_cast(buf.size()) / (vec[0].total() * vec[0].channels())) * 100.0 << "%" << std::endl; diff --git a/modules/ml/perf/perf_knn.cpp b/modules/ml/perf/perf_knn.cpp deleted file mode 100644 index f911b6520e..0000000000 --- a/modules/ml/perf/perf_knn.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// 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 "perf_precomp.hpp" - -namespace opencv_test { namespace { - -// KNN brute-force findNearest: dominated by the per-sample L2 distance reduction. -typedef TestBaseWithParam< tuple > KNNFindNearest; // (train samples, dims, K) - -PERF_TEST_P(KNNFindNearest, brute_force, testing::Values( - make_tuple(5000, 128, 5), - make_tuple(10000, 64, 10))) -{ - const int nsamples = get<0>(GetParam()); - const int dims = get<1>(GetParam()); - const int K = get<2>(GetParam()); - const int nquery = 2000; - - Mat train(nsamples, dims, CV_32F), responses(nsamples, 1, CV_32F), query(nquery, dims, CV_32F); - RNG& rng = theRNG(); - rng.fill(train, RNG::UNIFORM, 0.f, 1.f); - rng.fill(query, RNG::UNIFORM, 0.f, 1.f); - for (int i = 0; i < nsamples; i++) - responses.at(i) = (float)(i & 1); - - Ptr knn = KNearest::create(); - knn->setAlgorithmType(KNearest::BRUTE_FORCE); - knn->setDefaultK(K); - knn->train(train, ROW_SAMPLE, responses); - - Mat results, neighbors, dists; - TEST_CYCLE() knn->findNearest(query, K, results, neighbors, dists); - - SANITY_CHECK_NOTHING(); -} - -}} // namespace diff --git a/modules/ml/perf/perf_main.cpp b/modules/ml/perf/perf_main.cpp deleted file mode 100644 index ccdf300c6e..0000000000 --- a/modules/ml/perf/perf_main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// 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 "perf_precomp.hpp" - -CV_PERF_TEST_MAIN(ml) diff --git a/modules/ml/perf/perf_precomp.hpp b/modules/ml/perf/perf_precomp.hpp deleted file mode 100644 index de2c7acaba..0000000000 --- a/modules/ml/perf/perf_precomp.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// 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_PERF_PRECOMP_HPP__ -#define __OPENCV_PERF_PRECOMP_HPP__ - -#include -#include - -namespace opencv_test { -using namespace perf; -using namespace cv::ml; -} - -#endif diff --git a/modules/ml/perf/perf_svm.cpp b/modules/ml/perf/perf_svm.cpp deleted file mode 100644 index b47c367a88..0000000000 --- a/modules/ml/perf/perf_svm.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// 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 "perf_precomp.hpp" - -namespace opencv_test { namespace { - -// SVM::predict is dominated by the per-feature kernel reduction over the support -// vectors: calc_non_rbf_base (LINEAR/POLY/SIGMOID dot product), calc_rbf -// (squared distance), calc_intersec (min-sum) and calc_chi2. Train data is kept -// non-negative so the INTER and CHI2 kernels stay in their valid domain. -typedef TestBaseWithParam< tuple > SVMPredict; // (samples, dims, kernelType) - -PERF_TEST_P(SVMPredict, kernels, testing::Combine( - testing::Values(1500), - testing::Values(512), - testing::Values((int)SVM::RBF, (int)SVM::POLY, (int)SVM::INTER, (int)SVM::CHI2))) -{ - const int nsamples = get<0>(GetParam()); - const int dims = get<1>(GetParam()); - const int kernel = get<2>(GetParam()); - const int nquery = 1000; - - Mat train(nsamples, dims, CV_32F), query(nquery, dims, CV_32F); - Mat responses(nsamples, 1, CV_32S); - RNG& rng = theRNG(); - rng.fill(train, RNG::UNIFORM, 0.f, 1.f); - rng.fill(query, RNG::UNIFORM, 0.f, 1.f); - for (int i = 0; i < nsamples; i++) - responses.at(i) = i & 1; - - Ptr svm = SVM::create(); - svm->setType(SVM::C_SVC); - svm->setKernel(kernel); - svm->setC(1); - svm->setGamma(0.1); - svm->setDegree(3); // POLY - svm->setCoef0(1); // POLY - svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, 1000, 1e-3)); - svm->train(train, ROW_SAMPLE, responses); - - Mat results; - TEST_CYCLE() svm->predict(query, results); - - SANITY_CHECK_NOTHING(); -} - -}} // namespace diff --git a/modules/objdetect/test/test_qr_utils.hpp b/modules/objdetect/test/test_qr_utils.hpp index 5186acc7ad..ad631aabb3 100644 --- a/modules/objdetect/test/test_qr_utils.hpp +++ b/modules/objdetect/test/test_qr_utils.hpp @@ -71,8 +71,7 @@ void check_qr(const string& root, const string& name_current_image, const string return; // done } } - FAIL() << "Not found results for '" << name_current_image << "' image in config file:" << dataset_config << - "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data.\n"; + FAIL() << "Not found results for '" << name_current_image << "' image in config file:" << dataset_config; } } diff --git a/modules/objdetect/test/test_qrcode.cpp b/modules/objdetect/test/test_qrcode.cpp index 9db000a72a..1d48172daa 100644 --- a/modules/objdetect/test/test_qrcode.cpp +++ b/modules/objdetect/test/test_qrcode.cpp @@ -36,207 +36,6 @@ std::string qrcode_images_multiple[] = { static std::set> disabled_samples = {{"5_qrcodes.png", "aruco_based"}}; -//#define UPDATE_QRCODE_TEST_DATA -#ifdef UPDATE_QRCODE_TEST_DATA - -TEST(Objdetect_QRCode, generate_test_data) -{ - const std::string root = "qrcode/"; - const std::string dataset_config = findDataFile(root + "dataset_config.json"); - FileStorage file_config(dataset_config, FileStorage::WRITE); - - file_config << "test_images" << "["; - size_t images_count = sizeof(qrcode_images_name) / sizeof(qrcode_images_name[0]); - for (size_t i = 0; i < images_count; i++) - { - file_config << "{:" << "image_name" << qrcode_images_name[i]; - std::string image_path = findDataFile(root + qrcode_images_name[i]); - std::vector corners; - Mat src = imread(image_path, IMREAD_GRAYSCALE), straight_barcode; - std::string decoded_info; - ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path; - EXPECT_TRUE(detectQRCode(src, corners)); - EXPECT_TRUE(decodeQRCode(src, corners, decoded_info, straight_barcode)); - - file_config << "x" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].x; } - file_config << "]"; - file_config << "y" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].y; } - file_config << "]"; - file_config << "info" << decoded_info; - file_config << "}"; - } - file_config << "]"; - file_config.release(); -} - -TEST(Objdetect_QRCode_Close, generate_test_data) -{ - const std::string root = "qrcode/close/"; - const std::string dataset_config = findDataFile(root + "dataset_config.json"); - FileStorage file_config(dataset_config, FileStorage::WRITE); - - file_config << "close_images" << "["; - size_t close_count = sizeof(qrcode_images_close) / sizeof(qrcode_images_close[0]); - for (size_t i = 0; i < close_count; i++) - { - file_config << "{:" << "image_name" << qrcode_images_close[i]; - std::string image_path = findDataFile(root + qrcode_images_close[i]); - std::vector corners; - Mat src = imread(image_path, IMREAD_GRAYSCALE), barcode, straight_barcode; - std::string decoded_info; - ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path; - const double min_side = std::min(src.size().width, src.size().height); - double coeff_expansion = 1024.0 / min_side; - const int width = cvRound(src.size().width * coeff_expansion); - const int height = cvRound(src.size().height * coeff_expansion); - Size new_size(width, height); - resize(src, barcode, new_size, 0, 0, INTER_LINEAR_EXACT); - EXPECT_TRUE(detectQRCode(barcode, corners)); - EXPECT_TRUE(decodeQRCode(barcode, corners, decoded_info, straight_barcode)); - - file_config << "x" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].x; } - file_config << "]"; - file_config << "y" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].y; } - file_config << "]"; - file_config << "info" << decoded_info; - file_config << "}"; - } - file_config << "]"; - file_config.release(); -} -TEST(Objdetect_QRCode_Monitor, generate_test_data) -{ - const std::string root = "qrcode/monitor/"; - const std::string dataset_config = findDataFile(root + "dataset_config.json"); - FileStorage file_config(dataset_config, FileStorage::WRITE); - - file_config << "monitor_images" << "["; - size_t monitor_count = sizeof(qrcode_images_monitor) / sizeof(qrcode_images_monitor[0]); - for (size_t i = 0; i < monitor_count; i++) - { - file_config << "{:" << "image_name" << qrcode_images_monitor[i]; - std::string image_path = findDataFile(root + qrcode_images_monitor[i]); - std::vector corners; - Mat src = imread(image_path, IMREAD_GRAYSCALE), barcode, straight_barcode; - std::string decoded_info; - ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path; - const double min_side = std::min(src.size().width, src.size().height); - double coeff_expansion = 1024.0 / min_side; - const int width = cvRound(src.size().width * coeff_expansion); - const int height = cvRound(src.size().height * coeff_expansion); - Size new_size(width, height); - resize(src, barcode, new_size, 0, 0, INTER_LINEAR_EXACT); - EXPECT_TRUE(detectQRCode(barcode, corners)); - EXPECT_TRUE(decodeQRCode(barcode, corners, decoded_info, straight_barcode)); - - file_config << "x" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].x; } - file_config << "]"; - file_config << "y" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].y; } - file_config << "]"; - file_config << "info" << decoded_info; - file_config << "}"; - } - file_config << "]"; - file_config.release(); -} -TEST(Objdetect_QRCode_Curved, generate_test_data) -{ - const std::string root = "qrcode/curved/"; - const std::string dataset_config = findDataFile(root + "dataset_config.json"); - FileStorage file_config(dataset_config, FileStorage::WRITE); - - file_config << "test_images" << "["; - size_t images_count = sizeof(qrcode_images_curved) / sizeof(qrcode_images_curved[0]); - for (size_t i = 0; i < images_count; i++) - { - file_config << "{:" << "image_name" << qrcode_images_curved[i]; - std::string image_path = findDataFile(root + qrcode_images_curved[i]); - std::vector corners; - Mat src = imread(image_path, IMREAD_GRAYSCALE), straight_barcode; - std::string decoded_info; - ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path; - EXPECT_TRUE(detectQRCode(src, corners)); - EXPECT_TRUE(decodeCurvedQRCode(src, corners, decoded_info, straight_barcode)); - - file_config << "x" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].x; } - file_config << "]"; - file_config << "y" << "[:"; - for (size_t j = 0; j < corners.size(); j++) { file_config << corners[j].y; } - file_config << "]"; - file_config << "info" << decoded_info; - file_config << "}"; - } - file_config << "]"; - file_config.release(); -} -TEST(Objdetect_QRCode_Multi, generate_test_data) -{ - const std::string root = "qrcode/multiple/"; - const std::string dataset_config = findDataFile(root + "dataset_config.json"); - FileStorage file_config(dataset_config, FileStorage::WRITE); - - file_config << "multiple_images" << "[:"; - size_t multiple_count = sizeof(qrcode_images_multiple) / sizeof(qrcode_images_multiple[0]); - for (size_t i = 0; i < multiple_count; i++) - { - file_config << "{:" << "image_name" << qrcode_images_multiple[i]; - std::string image_path = findDataFile(root + qrcode_images_multiple[i]); - Mat src = imread(image_path); - - ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path; - std::vector corners; - QRCodeDetector qrcode; - EXPECT_TRUE(qrcode.detectMulti(src, corners)); - std::vector decoded_info; - std::vector straight_barcode; - EXPECT_TRUE(qrcode.decodeMulti(src, corners, decoded_info, straight_barcode)); - - file_config << "x" << "[:"; - for(size_t j = 0; j < corners.size(); j += 4) - { - file_config << "[:"; - for (size_t k = 0; k < 4; k++) - { - file_config << corners[j + k].x; - } - file_config << "]"; - } - file_config << "]"; - file_config << "y" << "[:"; - for(size_t j = 0; j < corners.size(); j += 4) - { - file_config << "[:"; - for (size_t k = 0; k < 4; k++) - { - file_config << corners[j + k].y; - } - file_config << "]"; - } - file_config << "]"; - file_config << "info"; - file_config << "[:"; - - for(size_t j = 0; j < decoded_info.size(); j++) - { - file_config << decoded_info[j]; - } - file_config << "]"; - file_config << "}"; - } - - file_config << "]"; - file_config.release(); -} - -#else - typedef testing::TestWithParam< std::string > Objdetect_QRCode; TEST_P(Objdetect_QRCode, regression) { @@ -643,8 +442,6 @@ TEST_P(Objdetect_QRCode_detectAndDecodeMulti, decode_9_qrcodes_version7) } } -#endif // UPDATE_QRCODE_TEST_DATA - TEST(Objdetect_QRCode_detectAndDecode, utf8_output) { const std::string name_current_image = "umlaut.png"; diff --git a/modules/objdetect/test/test_qrcode_encode.cpp b/modules/objdetect/test/test_qrcode_encode.cpp index f90af1d9f9..4681a2ef69 100644 --- a/modules/objdetect/test/test_qrcode_encode.cpp +++ b/modules/objdetect/test/test_qrcode_encode.cpp @@ -71,52 +71,6 @@ int establishCapacity(QRCodeEncoder::EncodeMode mode, int version, int capacity) return result; } -// #define UPDATE_TEST_DATA -#ifdef UPDATE_TEST_DATA - -TEST(Objdetect_QRCode_Encode, generate_test_data) -{ - const std::string root = "qrcode/encode"; - const std::string dataset_config = findDataFile(root + "/" + "dataset_config.json"); - FileStorage file_config(dataset_config, FileStorage::WRITE); - - file_config << "test_images" << "["; - size_t images_count = sizeof(encode_qrcode_images_name) / sizeof(encode_qrcode_images_name[0]); - for (size_t i = 0; i < images_count; i++) - { - file_config << "{:" << "image_name" << encode_qrcode_images_name[i]; - std::string image_path = findDataFile(root + "/" + encode_qrcode_images_name[i]); - - Mat src = imread(image_path, IMREAD_GRAYSCALE); - Mat straight_barcode; - EXPECT_TRUE(!src.empty()) << "Can't read image: " << image_path; - - std::vector corners(4); - corners[0] = Point2f(border_width, border_width); - corners[1] = Point2f(qrcode.cols * 1.0f - border_width, border_width); - corners[2] = Point2f(qrcode.cols * 1.0f - border_width, qrcode.rows * 1.0f - border_width); - corners[3] = Point2f(border_width, qrcode.rows * 1.0f - border_width); - - Mat resized_src; - resize(qrcode, resized_src, fixed_size, 0, 0, INTER_AREA); - float width_ratio = resized_src.cols * 1.0f / qrcode.cols; - float height_ratio = resized_src.rows * 1.0f / qrcode.rows; - for(size_t j = 0; j < corners.size(); j++) - { - corners[j].x = corners[j].x * width_ratio; - corners[j].y = corners[j].y * height_ratio; - } - - std::string decoded_info = ""; - EXPECT_TRUE(decodeQRCode(resized_src, corners, decoded_info, straight_barcode)) << "The QR code cannot be decoded: " << image_path; - file_config << "info" << decoded_info; - file_config << "}"; - } - file_config << "]"; - file_config.release(); -} -#else - typedef testing::TestWithParam< std::string > Objdetect_QRCode_Encode; TEST_P(Objdetect_QRCode_Encode, regression) { const int pixels_error = 3; @@ -155,8 +109,7 @@ TEST_P(Objdetect_QRCode_Encode, regression) { return; // done } } - FAIL() << "Not found results in config file:" << dataset_config - << "\nRe-run tests with enabled UPDATE_ENCODE_TEST_DATA macro to update test data."; + FAIL() << "Not found results in config file:" << dataset_config; } } @@ -200,8 +153,7 @@ TEST_P(Objdetect_QRCode_Encode_ECI, regression) { return; // done } } - FAIL() << "Not found results in config file:" << dataset_config - << "\nRe-run tests with enabled UPDATE_ENCODE_TEST_DATA macro to update test data."; + FAIL() << "Not found results in config file:" << dataset_config; } } @@ -430,8 +382,6 @@ TEST(Objdetect_QRCode_Encode_Decode_Structured_Append, regression) } } -#endif // UPDATE_QRCODE_TEST_DATA - CV_ENUM(EncodeModes, QRCodeEncoder::EncodeMode::MODE_NUMERIC, QRCodeEncoder::EncodeMode::MODE_ALPHANUMERIC, QRCodeEncoder::EncodeMode::MODE_BYTE) diff --git a/modules/photo/perf/opencl/perf_denoising.cpp b/modules/photo/perf/opencl/perf_denoising.cpp index 2088815795..0307c68995 100644 --- a/modules/photo/perf/opencl/perf_denoising.cpp +++ b/modules/photo/perf/opencl/perf_denoising.cpp @@ -45,7 +45,7 @@ OCL_PERF_TEST(Photo, DenoisingColored) SANITY_CHECK(result, 2); } -OCL_PERF_TEST(Photo, DISABLED_DenoisingGrayscaleMulti) +OCL_PERF_TEST(Photo, DenoisingGrayscaleMulti) { const int imgs_count = 3; @@ -68,7 +68,7 @@ OCL_PERF_TEST(Photo, DISABLED_DenoisingGrayscaleMulti) SANITY_CHECK(result); } -OCL_PERF_TEST(Photo, DISABLED_DenoisingColoredMulti) +OCL_PERF_TEST(Photo, DenoisingColoredMulti) { const int imgs_count = 3; @@ -89,7 +89,7 @@ OCL_PERF_TEST(Photo, DISABLED_DenoisingColoredMulti) OCL_TEST_CYCLE() cv::fastNlMeansDenoisingColoredMulti(original, result, imgs_count / 2, imgs_count, 10, 15); - SANITY_CHECK(result); + SANITY_CHECK(result, 2); } } } // namespace opencv_test::ocl diff --git a/modules/video/perf/perf_optflowpyrlk.cpp b/modules/video/perf/perf_optflowpyrlk.cpp index 158ac2b0ee..5dfaeaa9f5 100644 --- a/modules/video/perf/perf_optflowpyrlk.cpp +++ b/modules/video/perf/perf_optflowpyrlk.cpp @@ -92,57 +92,6 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine( SANITY_CHECK_NOTHING(); } -typedef tuple, int> Path_Idx_NPoints_WSize_t; -typedef TestBaseWithParam Path_Idx_NPoints_WSize; - -PERF_TEST_P(Path_Idx_NPoints_WSize, DISABLED_OpticalFlowPyrLK_ovx, testing::Combine( - testing::Values("cv/optflow/frames/VGA_%02d.png", "cv/optflow/frames/720p_%02d.png"), - testing::Range(1, 3), - testing::Values(make_tuple(9, 9), make_tuple(15, 15)), - testing::Values(7, 11) - ) - ) -{ - string filename1 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam()))); - string filename2 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam()) + 1)); - Mat img1 = imread(filename1); - Mat img2 = imread(filename2); - if (img1.empty()) FAIL() << "Unable to load source image " << filename1; - if (img2.empty()) FAIL() << "Unable to load source image " << filename2; - - int nPointsX = std::min(get<0>(get<2>(GetParam())), img1.cols); - int nPointsY = std::min(get<1>(get<2>(GetParam())), img1.rows); - int winSize = get<3>(GetParam()); - - int maxLevel = 2; - TermCriteria criteria(TermCriteria::COUNT|TermCriteria::EPS, 7, 0.001); - int flags = 0; - double minEigThreshold = 1e-4; - - Mat frame1, frame2; - cvtColor(img1, frame1, COLOR_BGR2GRAY, 1); - cvtColor(img2, frame2, COLOR_BGR2GRAY, 1); - - vector inPoints; - vector outPoints; - vector status; - - FormTrackingPointsArray(inPoints, frame1.cols, frame1.rows, nPointsX, nPointsY); - outPoints.resize(inPoints.size()); - status.resize(inPoints.size()); - - declare.in(frame1, frame2, inPoints).out(outPoints); - - TEST_CYCLE() - { - calcOpticalFlowPyrLK(frame1, frame2, inPoints, outPoints, status, cv::noArray(), - Size(winSize, winSize), maxLevel, criteria, - flags, minEigThreshold); - } - - SANITY_CHECK_NOTHING(); -} - typedef tuple, int, bool> Path_Idx_Cn_NPoints_WSize_Deriv_t; typedef TestBaseWithParam Path_Idx_Cn_NPoints_WSize_Deriv;