mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #15190 from andrey-golubev:fluid_invalid_roi
G-API: verify y offset and height of Fluid output ROIs (#15190) * G-API: validate GFluidOutputRoi y and height * Rearrange tested ROIs
This commit is contained in:
committed by
Alexander Alekhin
parent
304e3ac12f
commit
fc85f3644d
@@ -752,7 +752,8 @@ INSTANTIATE_TEST_CASE_P(Fluid, NV12RoiTest,
|
||||
,std::make_pair(cv::Size{1920, 1080}, cv::Rect{0, 710, 1920, 270})
|
||||
));
|
||||
|
||||
TEST(Fluid, UnusedNodeOutputCompileTest) {
|
||||
TEST(Fluid, UnusedNodeOutputCompileTest)
|
||||
{
|
||||
cv::GMat in;
|
||||
cv::GMat a, b, c, d;
|
||||
std::tie(a, b, c, d) = cv::gapi::split4(in);
|
||||
@@ -767,7 +768,8 @@ TEST(Fluid, UnusedNodeOutputCompileTest) {
|
||||
cv::compile_args(cv::gapi::core::fluid::kernels())));
|
||||
}
|
||||
|
||||
TEST(Fluid, UnusedNodeOutputReshapeTest) {
|
||||
TEST(Fluid, UnusedNodeOutputReshapeTest)
|
||||
{
|
||||
const auto test_size = cv::Size(8, 8);
|
||||
const auto get_compile_args =
|
||||
[] () { return cv::compile_args(cv::gapi::core::fluid::kernels()); };
|
||||
@@ -791,4 +793,37 @@ TEST(Fluid, UnusedNodeOutputReshapeTest) {
|
||||
ASSERT_NO_THROW(compiled(in_mat, out_mat));
|
||||
}
|
||||
|
||||
TEST(Fluid, InvalidROIs)
|
||||
{
|
||||
cv::GMat in;
|
||||
cv::GMat out = cv::gapi::add(in, in);
|
||||
|
||||
cv::Mat in_mat(cv::Size(8, 8), CV_8UC3);
|
||||
cv::Mat out_mat = in_mat.clone();
|
||||
cv::randu(in_mat, cv::Scalar::all(0), cv::Scalar::all(100));
|
||||
|
||||
std::vector<cv::Rect> invalid_rois =
|
||||
{
|
||||
cv::Rect(1, 0, 0, 0),
|
||||
cv::Rect(0, 1, 0, 0),
|
||||
cv::Rect(0, 0, 1, 0),
|
||||
cv::Rect(0, 0, 0, 1),
|
||||
cv::Rect(0, 0, out_mat.cols, 0),
|
||||
cv::Rect(0, 0, 0, out_mat.rows),
|
||||
cv::Rect(0, out_mat.rows, out_mat.cols, out_mat.rows),
|
||||
cv::Rect(out_mat.cols, 0, out_mat.cols, out_mat.rows),
|
||||
};
|
||||
|
||||
const auto compile_args = [] (cv::Rect roi) {
|
||||
return cv::compile_args(cv::gapi::core::fluid::kernels(), GFluidOutputRois{{to_own(roi)}});
|
||||
};
|
||||
|
||||
for (const auto& roi : invalid_rois)
|
||||
{
|
||||
cv::GComputation comp(cv::GIn(in), cv::GOut(out));
|
||||
EXPECT_THROW(comp.apply(cv::gin(in_mat), cv::gout(out_mat), compile_args(roi)),
|
||||
std::exception);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
||||
Reference in New Issue
Block a user