mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge branch 4.x
This commit is contained in:
@@ -26,11 +26,14 @@ INSTANTIATE_TEST_CASE_P(CPU_Tests, TestGAPIStereo,
|
||||
Values(STEREO_CPU),
|
||||
Values(cv::gapi::StereoOutputFormat::DEPTH_FLOAT16,
|
||||
cv::gapi::StereoOutputFormat::DEPTH_FLOAT32,
|
||||
cv::gapi::StereoOutputFormat::DISPARITY_FIXED16_12_4),
|
||||
cv::gapi::StereoOutputFormat::DISPARITY_FIXED16_12_4,
|
||||
cv::gapi::StereoOutputFormat::DEPTH_16F,
|
||||
cv::gapi::StereoOutputFormat::DEPTH_32F,
|
||||
cv::gapi::StereoOutputFormat::DISPARITY_16Q_11_4),
|
||||
Values(16),
|
||||
Values(43),
|
||||
Values(10.),
|
||||
Values(100.),
|
||||
Values(63.5),
|
||||
Values(3.6),
|
||||
Values(AbsExact().to_compare_obj())));
|
||||
|
||||
} // opencv_test
|
||||
|
||||
@@ -174,4 +174,11 @@ TEST(MediaFrame, Callback) {
|
||||
EXPECT_EQ(3, counter);
|
||||
}
|
||||
|
||||
TEST(MediaFrame, blobParams) {
|
||||
cv::Mat bgr = cv::Mat::eye(240, 320, CV_8UC3);
|
||||
cv::MediaFrame frame = cv::MediaFrame::Create<TestMediaBGR>(bgr);
|
||||
|
||||
EXPECT_NO_THROW(frame.blobParams());
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
||||
@@ -37,6 +37,31 @@ namespace
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct GCompiledValidateMetaEmpty: public ::testing::Test
|
||||
{
|
||||
cv::GMat in;
|
||||
cv::GScalar scale;
|
||||
cv::GComputation m_ucc;
|
||||
|
||||
G_API_OP(GReturn42, <cv::GOpaque<int>(cv::GMat)>, "org.opencv.test.return_42")
|
||||
{
|
||||
static GOpaqueDesc outMeta(cv::GMatDesc /* in */) { return cv::empty_gopaque_desc(); }
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GOCVReturn42, GReturn42)
|
||||
{
|
||||
static void run(const cv::Mat &/* in */, int &out)
|
||||
{
|
||||
out = 42;
|
||||
}
|
||||
};
|
||||
|
||||
GCompiledValidateMetaEmpty() : m_ucc(cv::GIn(in),
|
||||
cv::GOut(GReturn42::on(in)))
|
||||
{
|
||||
}
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_F(GCompiledValidateMetaTyped, ValidMeta)
|
||||
@@ -170,4 +195,38 @@ TEST_F(GCompiledValidateMetaUntyped, InvalidMetaNumber)
|
||||
EXPECT_THROW(f(cv::gin(in1, sc), cv::gout(out1, out2)), std::logic_error);
|
||||
}
|
||||
|
||||
TEST_F(GCompiledValidateMetaEmpty, InvalidMatMetaCompile)
|
||||
{
|
||||
EXPECT_THROW(m_ucc.compile(cv::empty_gmat_desc(),
|
||||
cv::empty_scalar_desc()),
|
||||
std::logic_error);
|
||||
}
|
||||
|
||||
TEST_F(GCompiledValidateMetaEmpty, InvalidMatMetaApply)
|
||||
{
|
||||
cv::Mat emptyIn;
|
||||
int out {};
|
||||
const auto pkg = cv::gapi::kernels<GCompiledValidateMetaEmpty::GOCVReturn42>();
|
||||
|
||||
EXPECT_THROW(m_ucc.apply(cv::gin(emptyIn), cv::gout(out), cv::compile_args(pkg)),
|
||||
std::logic_error);
|
||||
}
|
||||
|
||||
TEST_F(GCompiledValidateMetaEmpty, ValidInvalidMatMetasApply)
|
||||
{
|
||||
int out {};
|
||||
const auto pkg = cv::gapi::kernels<GCompiledValidateMetaEmpty::GOCVReturn42>();
|
||||
|
||||
cv::Mat nonEmptyMat = cv::Mat::eye(cv::Size(64,32), CV_8UC1);
|
||||
m_ucc.apply(cv::gin(nonEmptyMat), cv::gout(out), cv::compile_args(pkg));
|
||||
EXPECT_EQ(out, 42);
|
||||
|
||||
cv::Mat emptyIn;
|
||||
EXPECT_THROW(m_ucc.apply(cv::gin(emptyIn), cv::gout(out), cv::compile_args(pkg)),
|
||||
std::logic_error);
|
||||
|
||||
out = 0;
|
||||
m_ucc.apply(cv::gin(nonEmptyMat), cv::gout(out), cv::compile_args(pkg));
|
||||
EXPECT_EQ(out, 42);
|
||||
}
|
||||
} // namespace opencv_test
|
||||
|
||||
@@ -56,6 +56,15 @@ public:
|
||||
cv::MediaFrame::View::Strides ss = { m_mat.step, 0u, 0u, 0u };
|
||||
return cv::MediaFrame::View(std::move(pp), std::move(ss), Cb{m_cb});
|
||||
}
|
||||
cv::util::any blobParams() const override {
|
||||
return std::make_pair<InferenceEngine::TensorDesc,
|
||||
InferenceEngine::ParamMap>({IE::Precision::U8,
|
||||
{1, 3, 300, 300},
|
||||
IE::Layout::NCHW},
|
||||
{{"HELLO", 42},
|
||||
{"COLOR_FORMAT",
|
||||
InferenceEngine::ColorFormat::NV12}});
|
||||
}
|
||||
};
|
||||
|
||||
class TestMediaNV12 final: public cv::MediaFrame::IAdapter {
|
||||
@@ -2028,6 +2037,21 @@ TEST_F(ROIList, CallInferMultipleTimes)
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(IEFrameAdapter, blobParams)
|
||||
{
|
||||
cv::Mat bgr = cv::Mat::eye(240, 320, CV_8UC3);
|
||||
cv::MediaFrame frame = cv::MediaFrame::Create<TestMediaBGR>(bgr);
|
||||
|
||||
auto expected = std::make_pair(IE::TensorDesc{IE::Precision::U8, {1, 3, 300, 300},
|
||||
IE::Layout::NCHW},
|
||||
IE::ParamMap{{"HELLO", 42}, {"COLOR_FORMAT",
|
||||
IE::ColorFormat::NV12}});
|
||||
|
||||
auto actual = cv::util::any_cast<decltype(expected)>(frame.blobParams());
|
||||
|
||||
EXPECT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
||||
#endif // HAVE_INF_ENGINE
|
||||
|
||||
Reference in New Issue
Block a user