mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #19322 from TolyaTalamanov:at/python-callbacks
[G-API] Introduce cv.gin/cv.descr_of for python * Implement cv.gin/cv.descr_of * Fix macos build * Fix gcomputation tests * Add test * Add using to a void exceeded length for windows build * Add using to a void exceeded length for windows build * Fix comments to review * Fix comments to review * Update from latest master * Avoid graph compilation to obtain in/out info * Fix indentation * Fix comments to review * Avoid using default in switches * Post output meta for giebackend
This commit is contained in:
committed by
GitHub
parent
7bcb51eded
commit
eb82ba36a3
@@ -91,8 +91,6 @@ namespace opencv_test
|
||||
}
|
||||
};
|
||||
|
||||
// NB: Check an apply specifically designed to be called from Python,
|
||||
// but can also be used from C++
|
||||
struct GComputationPythonApplyTest: public ::testing::Test
|
||||
{
|
||||
cv::Size sz;
|
||||
@@ -103,22 +101,28 @@ namespace opencv_test
|
||||
GComputationPythonApplyTest() : sz(cv::Size(300,300)), type(CV_8UC1),
|
||||
in_mat1(sz, type), in_mat2(sz, type), out_mat_ocv(sz, type),
|
||||
m_c([&](){
|
||||
cv::GMat in1, in2;
|
||||
cv::GMat out = in1 + in2;
|
||||
return cv::GComputation(cv::GIn(in1, in2), cv::GOut(out));
|
||||
})
|
||||
cv::GMat in1, in2;
|
||||
cv::GMat out = in1 + in2;
|
||||
return cv::GComputation(cv::GIn(in1, in2), cv::GOut(out));
|
||||
})
|
||||
{
|
||||
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(255));
|
||||
out_mat_ocv = in_mat1 + in_mat2;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
TEST_F(GComputationPythonApplyTest, WithoutSerialization)
|
||||
{
|
||||
auto output = m_c.apply(cv::gin(in_mat1, in_mat2));
|
||||
auto output = m_c.apply(cv::detail::ExtractArgsCallback{[this](const cv::GTypesInfo& info)
|
||||
{
|
||||
GAPI_Assert(info[0].shape == cv::GShape::GMAT);
|
||||
GAPI_Assert(info[1].shape == cv::GShape::GMAT);
|
||||
return cv::GRunArgs{in_mat1, in_mat2};
|
||||
}
|
||||
});
|
||||
|
||||
EXPECT_EQ(1u, output.size());
|
||||
|
||||
const auto& out_mat_gapi = cv::util::get<cv::Mat>(output[0]);
|
||||
@@ -130,7 +134,14 @@ namespace opencv_test
|
||||
auto p = cv::gapi::serialize(m_c);
|
||||
auto c = cv::gapi::deserialize<cv::GComputation>(p);
|
||||
|
||||
auto output = c.apply(cv::gin(in_mat1, in_mat2));
|
||||
auto output = c.apply(cv::detail::ExtractArgsCallback{[this](const cv::GTypesInfo& info)
|
||||
{
|
||||
GAPI_Assert(info[0].shape == cv::GShape::GMAT);
|
||||
GAPI_Assert(info[1].shape == cv::GShape::GMAT);
|
||||
return cv::GRunArgs{in_mat1, in_mat2};
|
||||
}
|
||||
});
|
||||
|
||||
EXPECT_EQ(1u, output.size());
|
||||
|
||||
const auto& out_mat_gapi = cv::util::get<cv::Mat>(output[0]);
|
||||
|
||||
Reference in New Issue
Block a user