提交 fb326a35 编写于 作者: R Ruslan Garnov

Added a reproducer

上级 d0032b07
......@@ -790,4 +790,65 @@ INSTANTIATE_TEST_CASE_P(Fluid, NV12PlusResizeTest,
cv::Size{ 32, 64}, cv::Rect{0, 48, 32, 16})
));
struct Preproc4lpiTest : public TestWithParam <std::tuple<cv::Size, cv::Size, cv::Rect>>{};
TEST_P(Preproc4lpiTest, Test)
{
using namespace gapi_test_kernels;
cv::Size in_sz, out_sz;
cv::Rect roi;
std::tie(in_sz, out_sz, roi) = GetParam();
int interp = cv::INTER_LINEAR;
cv::Mat in_mat = cv::Mat(in_sz, CV_8UC3);
cv::randn(in_mat, cv::Scalar::all(127.0f), cv::Scalar::all(40.f));
cv::Mat out_mat, out_mat_ocv;
cv::GMat in;
auto splitted = split3_4lpi(in);
cv::GMat resized[3] = { cv::gapi::resize(std::get<0>(splitted), out_sz, 0, 0, interp)
, cv::gapi::resize(std::get<1>(splitted), out_sz, 0, 0, interp)
, cv::gapi::resize(std::get<2>(splitted), out_sz, 0, 0, interp) };
auto out = merge3_4lpi(resized[0], resized[1], resized[2]);
cv::GComputation c(cv::GIn(in), cv::GOut(out));
auto pkg = cv::gapi::combine(cv::gapi::core::fluid::kernels(),
fluidResizeTestPackage(interp, in_sz, out_sz, 4),
cv::unite_policy::REPLACE);
c.apply(cv::gin(in_mat), cv::gout(out_mat)
,cv::compile_args(pkg, cv::GFluidOutputRois{{to_own(roi)}}));
cv::resize(in_mat, out_mat_ocv, out_sz, 0, 0, interp);
EXPECT_EQ(0, cv::countNonZero(out_mat(roi) != out_mat_ocv(roi)));
}
INSTANTIATE_TEST_CASE_P(Fluid, Preproc4lpiTest,
Values(std::make_tuple(cv::Size{8, 8},
cv::Size{4, 4}, cv::Rect{0, 0, 4, 4})
,std::make_tuple(cv::Size{8, 8},
cv::Size{4, 4}, cv::Rect{0, 0, 4, 1})
,std::make_tuple(cv::Size{8, 8},
cv::Size{4, 4}, cv::Rect{0, 1, 4, 2})
,std::make_tuple(cv::Size{8, 8},
cv::Size{4, 4}, cv::Rect{0, 2, 4, 2})
,std::make_tuple(cv::Size{24, 24},
cv::Size{12, 12}, cv::Rect{0, 0, 12, 3})
,std::make_tuple(cv::Size{24, 24},
cv::Size{12, 12}, cv::Rect{0, 3, 12, 3})
,std::make_tuple(cv::Size{64, 64},
cv::Size{49, 49}, cv::Rect{0, 0, 49, 49})
,std::make_tuple(cv::Size{64, 64},
cv::Size{49, 49}, cv::Rect{0, 0, 49, 12})
,std::make_tuple(cv::Size{64, 64},
cv::Size{49, 49}, cv::Rect{0, 11, 49, 15})
,std::make_tuple(cv::Size{64, 64},
cv::Size{49, 49}, cv::Rect{0, 39, 49, 10})
));
} // namespace opencv_test
......@@ -359,14 +359,12 @@ GAPI_FLUID_KERNEL(FPlusRow0, TPlusRow0, true)
}
};
GAPI_FLUID_KERNEL(FTestSplit3, cv::gapi::core::GSplit3, false)
static void split3Row(const cv::gapi::fluid::View &in,
cv::gapi::fluid::Buffer &o1,
cv::gapi::fluid::Buffer &o2,
cv::gapi::fluid::Buffer &o3)
{
static const int Window = 1;
static void run(const cv::gapi::fluid::View &in,
cv::gapi::fluid::Buffer &o1,
cv::gapi::fluid::Buffer &o2,
cv::gapi::fluid::Buffer &o3)
for (int l = 0; l < o1.lpi(); l++)
{
// std::cout << "Split3 {{{\n";
// std::cout << " a - "; in.debug(std::cout);
......@@ -375,10 +373,10 @@ GAPI_FLUID_KERNEL(FTestSplit3, cv::gapi::core::GSplit3, false)
// std::cout << " 3 - "; o3.debug(std::cout);
// std::cout << "}}} " << std::endl;;
const uint8_t* in_rgb = in.InLine<uint8_t>(0);
uint8_t* out_r = o1.OutLine<uint8_t>();
uint8_t* out_g = o2.OutLine<uint8_t>();
uint8_t* out_b = o3.OutLine<uint8_t>();
const uint8_t* in_rgb = in.InLine<uint8_t>(l);
uint8_t* out_r = o1.OutLine<uint8_t>(l);
uint8_t* out_g = o2.OutLine<uint8_t>(l);
uint8_t* out_b = o3.OutLine<uint8_t>(l);
for (int i = 0, w = in.length(); i < w; i++)
{
......@@ -387,8 +385,40 @@ GAPI_FLUID_KERNEL(FTestSplit3, cv::gapi::core::GSplit3, false)
out_b[i] = in_rgb[3*i+2];
}
}
}
GAPI_FLUID_KERNEL(FTestSplit3, cv::gapi::core::GSplit3, false)
{
static const int Window = 1;
static void run(const cv::gapi::fluid::View &in,
cv::gapi::fluid::Buffer &o1,
cv::gapi::fluid::Buffer &o2,
cv::gapi::fluid::Buffer &o3)
{
split3Row(in, o1, o2, o3);
}
};
GAPI_FLUID_KERNEL(FTestSplit3_4lpi, TSplit3_4lpi, false)
{
static const int Window = 1;
static const int LPI = 4;
static void run(const cv::gapi::fluid::View &in,
cv::gapi::fluid::Buffer &o1,
cv::gapi::fluid::Buffer &o2,
cv::gapi::fluid::Buffer &o3)
{
split3Row(in, o1, o2, o3);
}
};
std::tuple<GMat, GMat, GMat> split3_4lpi(const GMat& src)
{
return TSplit3_4lpi::on(src);
}
GAPI_FLUID_KERNEL(FSum2MatsAndScalar, TSum2MatsAndScalar, false)
{
static const int Window = 1;
......@@ -486,6 +516,39 @@ GAPI_FLUID_KERNEL(FNV12toRGB, cv::gapi::imgproc::GNV12toRGB, false)
}
};
GAPI_FLUID_KERNEL(FMerge3_4lpi, TMerge3_4lpi, false)
{
static const int Window = 1;
static const int LPI = 4;
static void run(const cv::gapi::fluid::View &src1,
const cv::gapi::fluid::View &src2,
const cv::gapi::fluid::View &src3,
cv::gapi::fluid::Buffer &dst)
{
for (int l = 0; l < dst.lpi(); l++)
{
const auto *in1 = src1.InLine<uchar>(l);
const auto *in2 = src2.InLine<uchar>(l);
const auto *in3 = src3.InLine<uchar>(l);
auto *out = dst.OutLine<uchar>(l);
for (int w = 0; w < dst.length(); w++)
{
out[3*w ] = in1[w];
out[3*w + 1] = in2[w];
out[3*w + 2] = in3[w];
}
}
}
};
GMat merge3_4lpi(const GMat& src1, const GMat& src2, const GMat& src3)
{
return TMerge3_4lpi::on(src1, src2, src3);
}
cv::gapi::GKernelPackage fluidTestPackage = cv::gapi::kernels
<FAddSimple
,FAddCSimple
......@@ -498,10 +561,12 @@ cv::gapi::GKernelPackage fluidTestPackage = cv::gapi::kernels
,FBlur5x5_2lpi
,FIdentity
,FId7x7
,FMerge3_4lpi
,FNV12toRGB
,FPlusRow0
,FSum2MatsAndScalar
,FTestSplit3
,FTestSplit3_4lpi
>();
} // namespace gapi_test_kernels
} // namespace cv
......@@ -14,6 +14,7 @@ namespace cv
{
namespace gapi_test_kernels
{
using cv::gapi::core::GMat3;
G_TYPED_KERNEL(TAddSimple, <GMat(GMat, GMat)>, "test.fluid.add_simple") {
static cv::GMatDesc outMeta(cv::GMatDesc a, cv::GMatDesc) {
......@@ -84,6 +85,12 @@ G_TYPED_KERNEL(TId7x7, <GMat(GMat)>, "test.fluid.identity7x7") {
}
};
G_TYPED_KERNEL(TMerge3_4lpi, <GMat(GMat,GMat,GMat)>, "test.fluid.merge3_4lpi") {
static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc) {
return in.withType(in.depth, 3);
}
};
G_TYPED_KERNEL(TPlusRow0, <GMat(GMat)>, "test.fluid.plus_row0") {
static cv::GMatDesc outMeta(cv::GMatDesc a) {
return a;
......@@ -97,6 +104,17 @@ G_TYPED_KERNEL(TSum2MatsAndScalar, <GMat(GMat,GScalar,GMat)>, "test.fluid.sum_2_
}
};
G_TYPED_KERNEL_M(TSplit3_4lpi, <GMat3(GMat)>, "test.fluid.split3_4lpi") {
static std::tuple<GMatDesc, GMatDesc, GMatDesc> outMeta(GMatDesc in) {
const auto out_depth = in.depth;
const auto out_desc = in.withType(out_depth, 1);
return std::make_tuple(out_desc, out_desc, out_desc);
}
};
GMat merge3_4lpi(const GMat& src1, const GMat& src2, const GMat& src3);
std::tuple<GMat, GMat, GMat> split3_4lpi(const GMat& src);
extern cv::gapi::GKernelPackage fluidTestPackage;
} // namespace gapi_test_kernels
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册