From 2f6d2b08aa6dcd60c3eb58d203aab370509f8535 Mon Sep 17 00:00:00 2001 From: Maxim Pashchenkov Date: Tue, 16 Nov 2021 21:27:42 +0300 Subject: [PATCH] Merge pull request #20995 from mpashchenkov:mp/ocv-gapi-tdp-skip G-API: Removing G-API test code that is a reflection of ts module * gapi: don't hijack testing infrastructure * Removed initDataPath functionality (ts module exists) * Removed false for ocv_extra data from findDataFile Co-authored-by: Alexander Alekhin --- .../gapi/perf/common/gapi_video_perf_tests_inl.hpp | 1 - modules/gapi/test/common/gapi_tests_common.hpp | 36 ------------------ modules/gapi/test/common/gapi_video_tests_inl.hpp | 2 - .../test/cpu/gapi_ocv_stateful_kernel_tests.cpp | 20 ---------- modules/gapi/test/gapi_graph_meta_tests.cpp | 23 ------------ modules/gapi/test/infer/gapi_infer_ie_test.cpp | 21 ----------- modules/gapi/test/infer/gapi_infer_onnx_test.cpp | 16 -------- .../gapi/test/streaming/gapi_streaming_tests.cpp | 43 +--------------------- modules/gapi/test/test_main.cpp | 2 +- 9 files changed, 3 insertions(+), 161 deletions(-) diff --git a/modules/gapi/perf/common/gapi_video_perf_tests_inl.hpp b/modules/gapi/perf/common/gapi_video_perf_tests_inl.hpp index 700d2f6..05439f6 100644 --- a/modules/gapi/perf/common/gapi_video_perf_tests_inl.hpp +++ b/modules/gapi/perf/common/gapi_video_perf_tests_inl.hpp @@ -159,7 +159,6 @@ PERF_TEST_P_(BuildPyr_CalcOptFlow_PipelinePerfTest, TestPerformance) PERF_TEST_P_(BackgroundSubtractorPerfTest, TestPerformance) { namespace gvideo = cv::gapi::video; - initTestDataPath(); gvideo::BackgroundSubtractorType opType; std::string filePath = ""; diff --git a/modules/gapi/test/common/gapi_tests_common.hpp b/modules/gapi/test/common/gapi_tests_common.hpp index 463e994..4c9c2d9 100644 --- a/modules/gapi/test/common/gapi_tests_common.hpp +++ b/modules/gapi/test/common/gapi_tests_common.hpp @@ -58,40 +58,6 @@ namespace return o; } - inline bool initTestDataPathSilent() - { -#ifndef WINRT - static bool initialized = false; - if (!initialized) - { - // Since G-API has no own test data (yet), it is taken from the common space - const char* testDataPath = getenv("OPENCV_TEST_DATA_PATH"); - if (testDataPath != nullptr) { - cvtest::addDataSearchPath(testDataPath); - initialized = true; - } - } - - return initialized; -#endif // WINRT - } - - inline void initTestDataPath() - { - bool initialized = initTestDataPathSilent(); - GAPI_Assert(initialized && - "OPENCV_TEST_DATA_PATH environment variable is either not set or set incorrectly."); - } - - inline void initTestDataPathOrSkip() - { - bool initialized = initTestDataPathSilent(); - if (!initialized) - { - throw cvtest::SkipTestException("Can't find test data"); - } - } - template inline void initPointRandU(cv::RNG &rng, cv::Point_& pt) { GAPI_Assert(std::is_integral::value); @@ -299,7 +265,6 @@ public: void initMatFromImage(int type, const std::string& fileName) { - initTestDataPath(); int channels = (type >> CV_CN_SHIFT) + 1; GAPI_Assert(channels == 1 || channels == 3 || channels == 4); @@ -323,7 +288,6 @@ public: void initMatsFromImages(int channels, const std::string& pattern, int imgNum) { - initTestDataPath(); GAPI_Assert(channels == 1 || channels == 3 || channels == 4); const int flags = (channels == 1) ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR; diff --git a/modules/gapi/test/common/gapi_video_tests_inl.hpp b/modules/gapi/test/common/gapi_video_tests_inl.hpp index 7827680..34cbbf2 100644 --- a/modules/gapi/test/common/gapi_video_tests_inl.hpp +++ b/modules/gapi/test/common/gapi_video_tests_inl.hpp @@ -92,8 +92,6 @@ TEST_P(BuildPyr_CalcOptFlow_PipelineTest, AccuracyTest) #ifdef HAVE_OPENCV_VIDEO TEST_P(BackgroundSubtractorTest, AccuracyTest) { - initTestDataPath(); - cv::gapi::video::BackgroundSubtractorType opType; double thr = -1; std::tie(opType, thr) = typeAndThreshold; diff --git a/modules/gapi/test/cpu/gapi_ocv_stateful_kernel_tests.cpp b/modules/gapi/test/cpu/gapi_ocv_stateful_kernel_tests.cpp index 416c141..239afc3 100644 --- a/modules/gapi/test/cpu/gapi_ocv_stateful_kernel_tests.cpp +++ b/modules/gapi/test/cpu/gapi_ocv_stateful_kernel_tests.cpp @@ -43,22 +43,6 @@ namespace opencv_test //----------------------------------------------- Simple tests ------------------------------------------------ namespace { - inline void initTestDataPath() - { -#ifndef WINRT - static bool initialized = false; - if (!initialized) - { - // Since G-API has no own test data (yet), it is taken from the common space - const char* testDataPath = getenv("OPENCV_TEST_DATA_PATH"); - if (testDataPath) { - cvtest::addDataSearchPath(testDataPath); - } - initialized = true; - } -#endif // WINRT - } - G_TYPED_KERNEL(GCountCalls, (GMat)>, "org.opencv.test.count_calls") { static GOpaqueDesc outMeta(GMatDesc /* in */) { return empty_gopaque_desc(); } @@ -181,8 +165,6 @@ TEST(StatefulKernel, StateIsMutableInRuntime) TEST(StatefulKernel, StateIsAutoResetForNewStream) { - initTestDataPath(); - cv::GMat in; cv::GOpaque out = GIsStateUpToDate::on(in); cv::GComputation c(cv::GIn(in), cv::GOut(out)); @@ -329,8 +311,6 @@ namespace TEST(StatefulKernel, StateIsInitViaCompArgsInStreaming) { - initTestDataPath(); - // G-API graph declaration cv::GMat in; cv::GMat out = GBackSub::on(in); diff --git a/modules/gapi/test/gapi_graph_meta_tests.cpp b/modules/gapi/test/gapi_graph_meta_tests.cpp index 1cc4c0c..e8d0b8b 100644 --- a/modules/gapi/test/gapi_graph_meta_tests.cpp +++ b/modules/gapi/test/gapi_graph_meta_tests.cpp @@ -13,23 +13,6 @@ namespace opencv_test { -namespace { -void initTestDataPath() { -#ifndef WINRT - static bool initialized = false; - if (!initialized) - { - // Since G-API has no own test data (yet), it is taken from the common space - const char* testDataPath = getenv("OPENCV_TEST_DATA_PATH"); - if (testDataPath != nullptr) { - cvtest::addDataSearchPath(testDataPath); - initialized = true; - } - } -#endif // WINRT -} -} // anonymous namespace - TEST(GraphMeta, Trad_AccessInput) { cv::GMat in; cv::GMat out1 = cv::gapi::blur(in, cv::Size(3,3)); @@ -91,8 +74,6 @@ TEST(GraphMeta, Trad_AccessOutput) { } TEST(GraphMeta, Streaming_AccessInput) { - initTestDataPath(); - cv::GMat in; cv::GMat out1 = cv::gapi::blur(in, cv::Size(3,3)); cv::GOpaque out2 = cv::gapi::streaming::seq_id(in); @@ -118,8 +99,6 @@ TEST(GraphMeta, Streaming_AccessInput) { } TEST(GraphMeta, Streaming_AccessOutput) { - initTestDataPath(); - cv::GMat in; cv::GMat out1 = cv::gapi::blur(in, cv::Size(3,3)); cv::GOpaque out2 = cv::gapi::streaming::seq_id(out1); @@ -151,8 +130,6 @@ TEST(GraphMeta, Streaming_AccessOutput) { } TEST(GraphMeta, Streaming_AccessDesync) { - initTestDataPath(); - cv::GMat in; cv::GOpaque out1 = cv::gapi::streaming::seq_id(in); cv::GOpaque out2 = cv::gapi::streaming::timestamp(in); diff --git a/modules/gapi/test/infer/gapi_infer_ie_test.cpp b/modules/gapi/test/infer/gapi_infer_ie_test.cpp index e6c5651..d15b419 100644 --- a/modules/gapi/test/infer/gapi_infer_ie_test.cpp +++ b/modules/gapi/test/infer/gapi_infer_ie_test.cpp @@ -39,21 +39,6 @@ namespace opencv_test { namespace { -void initTestDataPath() -{ -#ifndef WINRT - static bool initialized = false; - if (!initialized) - { - // Since G-API has no own test data (yet), it is taken from the common space - const char* testDataPath = getenv("OPENCV_TEST_DATA_PATH"); - if (testDataPath) { - cvtest::addDataSearchPath(testDataPath); - } - initialized = true; - } -#endif // WINRT -} class TestMediaBGR final: public cv::MediaFrame::IAdapter { cv::Mat m_mat; @@ -1489,7 +1474,6 @@ TEST(Infer, SetInvalidNumberOfRequests) TEST(Infer, TestStreamingInfer) { - initTestDataPath(); initDLDTDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); @@ -1557,7 +1541,6 @@ TEST(Infer, TestStreamingInfer) TEST(InferROI, TestStreamingInfer) { - initTestDataPath(); initDLDTDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); @@ -1636,7 +1619,6 @@ TEST(InferROI, TestStreamingInfer) TEST(InferList, TestStreamingInfer) { - initTestDataPath(); initDLDTDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); @@ -1726,7 +1708,6 @@ TEST(InferList, TestStreamingInfer) TEST(Infer2, TestStreamingInfer) { - initTestDataPath(); initDLDTDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); @@ -1817,7 +1798,6 @@ TEST(Infer2, TestStreamingInfer) TEST(InferEmptyList, TestStreamingInfer) { - initTestDataPath(); initDLDTDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); @@ -1872,7 +1852,6 @@ TEST(InferEmptyList, TestStreamingInfer) TEST(Infer2EmptyList, TestStreamingInfer) { - initTestDataPath(); initDLDTDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); diff --git a/modules/gapi/test/infer/gapi_infer_onnx_test.cpp b/modules/gapi/test/infer/gapi_infer_onnx_test.cpp index 1f21f95..5b1e6c9 100644 --- a/modules/gapi/test/infer/gapi_infer_onnx_test.cpp +++ b/modules/gapi/test/infer/gapi_infer_onnx_test.cpp @@ -83,21 +83,6 @@ cv::Mat initMatrixRandU(const int type, const cv::Size& sz_in) { namespace opencv_test { namespace { -void initTestDataPath() -{ -#ifndef WINRT - static bool initialized = false; - if (!initialized) - { - // Since G-API has no own test data (yet), it is taken from the common space - const char* testDataPath = getenv("OPENCV_TEST_DATA_PATH"); - if (testDataPath) { - cvtest::addDataSearchPath(testDataPath); - } - initialized = true; - } -#endif // WINRT -} // FIXME: taken from the DNN module void normAssert(cv::InputArray& ref, cv::InputArray& test, @@ -322,7 +307,6 @@ public: cv::Mat in_mat; ONNXtest() { - initTestDataPath(); env = Ort::Env(ORT_LOGGING_LEVEL_WARNING, "test"); memory_info = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault); out_gapi.resize(1); diff --git a/modules/gapi/test/streaming/gapi_streaming_tests.cpp b/modules/gapi/test/streaming/gapi_streaming_tests.cpp index 9eb9470..3b37e57 100644 --- a/modules/gapi/test/streaming/gapi_streaming_tests.cpp +++ b/modules/gapi/test/streaming/gapi_streaming_tests.cpp @@ -40,21 +40,6 @@ namespace opencv_test { namespace { -void initTestDataPath() -{ -#ifndef WINRT - static bool initialized = false; - if (!initialized) - { - // Since G-API has no own test data (yet), it is taken from the common space - const char* testDataPath = getenv("OPENCV_TEST_DATA_PATH"); - if (testDataPath) { - cvtest::addDataSearchPath(testDataPath); - } - initialized = true; - } -#endif // WINRT -} enum class KernelPackage: int { @@ -81,7 +66,6 @@ std::ostream& operator<< (std::ostream &os, const KernelPackage &e) struct GAPI_Streaming: public ::testing::TestWithParam>> { GAPI_Streaming() { - initTestDataPath(); KernelPackage pkg_kind; std::tie(pkg_kind, cap) = GetParam(); pkg = getKernelPackage(pkg_kind); @@ -846,8 +830,6 @@ TEST(GAPI_Streaming_Types, XChangeScalar) // This test verifies if Streaming works when pipeline steps // (islands) exchange Scalar data. - initTestDataPath(); - cv::GMat in; cv::GScalar m = cv::gapi::mean(in); cv::GMat tmp = cv::gapi::convertTo(in, CV_32F) - m; @@ -914,8 +896,6 @@ TEST(GAPI_Streaming_Types, XChangeVector) // This test verifies if Streaming works when pipeline steps // (islands) exchange Vector data. - initTestDataPath(); - cv::GMat in1, in2; cv::GMat in = cv::gapi::crop(in1, cv::Rect{0,0,576,576}); cv::GScalar m = cv::gapi::mean(in); @@ -980,8 +960,6 @@ TEST(GAPI_Streaming_Types, OutputScalar) // This test verifies if Streaming works when pipeline // produces scalar data only - initTestDataPath(); - cv::GMat in; cv::GScalar out = cv::gapi::mean(in); auto sc = cv::GComputation(cv::GIn(in), cv::GOut(out)) @@ -1019,7 +997,6 @@ TEST(GAPI_Streaming_Types, OutputVector) // This test verifies if Streaming works when pipeline // produces vector data only - initTestDataPath(); auto pkg = cv::gapi::kernels(); cv::GMat in1, in2; @@ -1181,7 +1158,6 @@ struct GAPI_Streaming_Unit: public ::testing::Test { return cv::GComputation(cv::GIn(a, b), cv::GOut(c)); }) { - initTestDataPath(); const auto a_desc = cv::descr_of(m); const auto b_desc = cv::descr_of(m); @@ -1196,7 +1172,6 @@ struct GAPI_Streaming_Unit: public ::testing::Test { TEST(GAPI_Streaming, TestTwoVideosDifferentLength) { - initTestDataPath(); auto desc = cv::GMatDesc{CV_8U,3,{768,576}}; auto path1 = findDataFile("cv/video/768x576.avi"); auto path2 = findDataFile("highgui/video/big_buck_bunny.avi"); @@ -1458,8 +1433,6 @@ TEST(GAPI_Streaming_Desync, SmokeTest_Regular) TEST(GAPI_Streaming_Desync, SmokeTest_Streaming) { - initTestDataPath(); - cv::GMat in; cv::GMat tmp1 = cv::gapi::boxFilter(in, -1, cv::Size(3,3)); cv::GMat out1 = cv::gapi::Canny(tmp1, 32, 128, 3); @@ -1491,8 +1464,6 @@ TEST(GAPI_Streaming_Desync, SmokeTest_Streaming) TEST(GAPI_Streaming_Desync, SmokeTest_Streaming_TwoParts) { - initTestDataPath(); - cv::GMat in; cv::GMat tmp1 = cv::gapi::boxFilter(in, -1, cv::Size(3,3)); cv::GMat out1 = cv::gapi::Canny(tmp1, 32, 128, 3); @@ -1628,8 +1599,6 @@ TEST(GAPI_Streaming_Desync, Negative_CrossOtherDesync_Tier1) TEST(GAPI_Streaming_Desync, Negative_SynchronizedPull) { - initTestDataPath(); - cv::GMat in; cv::GMat out1 = cv::gapi::boxFilter(in, -1, cv::Size(3,3)); @@ -1653,8 +1622,6 @@ TEST(GAPI_Streaming_Desync, Negative_SynchronizedPull) TEST(GAPI_Streaming_Desync, UseSpecialPull) { - initTestDataPath(); - cv::GMat in; cv::GMat out1 = cv::gapi::boxFilter(in, -1, cv::Size(3,3)); @@ -1811,7 +1778,6 @@ TEST(GAPI_Streaming_Desync, DesyncObjectConsumedByTwoIslandsViaSameDesync) { TEST(GAPI_Streaming, CopyFrame) { - initTestDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); cv::GFrame in; @@ -1850,7 +1816,6 @@ TEST(GAPI_Streaming, CopyFrame) TEST(GAPI_Streaming, CopyMat) { - initTestDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); cv::GMat in; @@ -1887,7 +1852,6 @@ TEST(GAPI_Streaming, CopyMat) TEST(GAPI_Streaming, Reshape) { - initTestDataPath(); std::string filepath = findDataFile("cv/video/768x576.avi"); cv::GFrame in; @@ -2077,8 +2041,7 @@ TEST_P(GAPI_Accessors_In_Streaming, AccuracyTest) auto accessor = gapi_functions[accessType]; auto fromBGR = ref_functions[std::make_pair(sourceType, accessType)]; - initTestDataPathOrSkip(); - const std::string& absFilePath = findDataFile(filepath, false); + const std::string& absFilePath = findDataFile(filepath); cv::GFrame in; cv::GMat out = accessor(in); @@ -2129,8 +2092,7 @@ TEST_P(GAPI_Accessors_Meta_In_Streaming, AccuracyTest) auto accessor = gapi_functions[accessType]; auto fromBGR = ref_functions[std::make_pair(sourceType, accessType)]; - initTestDataPathOrSkip(); - const std::string& absFilePath = findDataFile(filepath, false); + const std::string& absFilePath = findDataFile(filepath); cv::GFrame in; cv::GMat gmat = accessor(in); @@ -2328,7 +2290,6 @@ GAPI_OCV_KERNEL(GOcvTestBlur, GTestBlur) { }; TEST(GAPI_Streaming, TestDesyncMediaFrame) { - initTestDataPath(); cv::GFrame in; auto blurred = GTestBlur::on(in); auto desynced = cv::gapi::streaming::desync(blurred); diff --git a/modules/gapi/test/test_main.cpp b/modules/gapi/test/test_main.cpp index fa5862f..7e16afe 100644 --- a/modules/gapi/test/test_main.cpp +++ b/modules/gapi/test/test_main.cpp @@ -9,4 +9,4 @@ #include "test_precomp.hpp" -CV_TEST_MAIN("gapi") +CV_TEST_MAIN("") -- 2.7.4