1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-19 11:21:39 +08:00
Files
opencv_contrib/modules/gapi/test/gapi_compile_args_tests.cpp
Alexander Smorkalov 2d69dd1215 Merge pull request #3827 from asmorkalov:as/gapi_migration
Migrate G-API module from main repo to opencv_contrib #3827

Related to https://github.com/opencv/opencv/pull/26469
Required https://github.com/opencv/opencv/pull/26527
CI: https://github.com/opencv/ci-gha-workflow/pull/201

TODO:
- [x]  Python types generator fix
- [x] CI update

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-11-27 16:02:16 +03:00

76 lines
2.0 KiB
C++

// 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.
//
// Copyright (C) 2020 Intel Corporation
#include "test_precomp.hpp"
namespace opencv_test
{
struct CustomArg
{
int number;
};
}
namespace cv
{
namespace detail
{
template<> struct CompileArgTag<opencv_test::CustomArg>
{
static const char* tag() { return "org.opencv.test.custom_arg"; }
};
}
}
namespace opencv_test
{
namespace
{
G_TYPED_KERNEL(GTestOp, <GMat(GMat)>, "org.opencv.test.test_op")
{
static GMatDesc outMeta(GMatDesc in) { return in; }
};
GAPI_OCV_KERNEL(GOCVTestOp, GTestOp)
{
static void run(const cv::Mat &/* in */, cv::Mat &/* out */) { }
};
} // anonymous namespace
TEST(GetCompileArgTest, PredefinedArgs)
{
cv::GKernelPackage pkg = cv::gapi::kernels<GOCVTestOp>();
cv::GCompileArg arg0 { pkg },
arg1 { cv::gapi::use_only { pkg } },
arg2 { cv::graph_dump_path { "fake_path" } };
GCompileArgs compArgs { arg0, arg1, arg2 };
auto kernelPkgOpt = cv::gapi::getCompileArg<cv::GKernelPackage>(compArgs);
GAPI_Assert(kernelPkgOpt.has_value());
EXPECT_NO_THROW(kernelPkgOpt.value().lookup("org.opencv.test.test_op"));
auto hasUseOnlyOpt = cv::gapi::getCompileArg<cv::gapi::use_only>(compArgs);
GAPI_Assert(hasUseOnlyOpt.has_value());
EXPECT_NO_THROW(hasUseOnlyOpt.value().pkg.lookup("org.opencv.test.test_op"));
auto dumpInfoOpt = cv::gapi::getCompileArg<cv::graph_dump_path>(compArgs);
GAPI_Assert(dumpInfoOpt.has_value());
EXPECT_EQ("fake_path", dumpInfoOpt.value().m_dump_path);
}
TEST(GetCompileArg, CustomArgs)
{;
cv::GCompileArgs compArgs{ GCompileArg { CustomArg { 7 } } };
auto customArgOpt = cv::gapi::getCompileArg<CustomArg>(compArgs);
GAPI_Assert(customArgOpt.has_value());
EXPECT_EQ(7, customArgOpt.value().number);
}
} // namespace opencv_test