Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
faca45a7
Commit
faca45a7
authored
Apr 29, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14429 from rgarnov:gapi_fluid_fix_small_rois
parents
e8ac7a34
ffaf4d5d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
12 deletions
+157
-12
gfluidbackend.cpp
modules/gapi/src/backends/fluid/gfluidbackend.cpp
+2
-1
gapi_fluid_resize_test.cpp
modules/gapi/test/gapi_fluid_resize_test.cpp
+61
-0
gapi_fluid_test_kernels.cpp
modules/gapi/test/gapi_fluid_test_kernels.cpp
+76
-11
gapi_fluid_test_kernels.hpp
modules/gapi/test/gapi_fluid_test_kernels.hpp
+18
-0
No files found.
modules/gapi/src/backends/fluid/gfluidbackend.cpp
View file @
faca45a7
...
...
@@ -371,7 +371,8 @@ std::pair<int,int> cv::gimpl::FluidUpscaleMapper::linesReadAndNextWindow(int out
int
cv
::
gimpl
::
FluidFilterAgent
::
firstWindow
(
std
::
size_t
)
const
{
return
k
.
m_window
+
k
.
m_lpi
-
1
;
int
lpi
=
std
::
min
(
k
.
m_lpi
,
m_outputLines
-
m_producedLines
);
return
k
.
m_window
+
lpi
-
1
;
}
std
::
pair
<
int
,
int
>
cv
::
gimpl
::
FluidFilterAgent
::
linesReadAndnextWindow
(
std
::
size_t
)
const
...
...
modules/gapi/test/gapi_fluid_resize_test.cpp
View file @
faca45a7
...
...
@@ -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.0
f
),
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
modules/gapi/test/gapi_fluid_test_kernels.cpp
View file @
faca45a7
...
...
@@ -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
modules/gapi/test/gapi_fluid_test_kernels.hpp
View file @
faca45a7
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment