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
576644a1
Commit
576644a1
authored
Aug 23, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15236 from dbudniko:dbudniko/g_api_copy_kernels
parents
ccecd340
64277440
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
173 additions
and
0 deletions
+173
-0
core.hpp
modules/gapi/include/opencv2/gapi/core.hpp
+19
-0
gapi_core_perf_tests.hpp
modules/gapi/perf/common/gapi_core_perf_tests.hpp
+1
-0
gapi_core_perf_tests_inl.hpp
modules/gapi/perf/common/gapi_core_perf_tests_inl.hpp
+34
-0
gapi_core_perf_tests_cpu.cpp
modules/gapi/perf/cpu/gapi_core_perf_tests_cpu.cpp
+5
-0
gapi_core_perf_tests_gpu.cpp
modules/gapi/perf/gpu/gapi_core_perf_tests_gpu.cpp
+5
-0
kernels_core.cpp
modules/gapi/src/api/kernels_core.cpp
+5
-0
gcpucore.cpp
modules/gapi/src/backends/cpu/gcpucore.cpp
+9
-0
gfluidcore.cpp
modules/gapi/src/backends/fluid/gfluidcore.cpp
+35
-0
goclcore.cpp
modules/gapi/src/backends/ocl/goclcore.cpp
+9
-0
gapi_core_tests.hpp
modules/gapi/test/common/gapi_core_tests.hpp
+1
-0
gapi_core_tests_inl.hpp
modules/gapi/test/common/gapi_core_tests_inl.hpp
+26
-0
gapi_core_tests_cpu.cpp
modules/gapi/test/cpu/gapi_core_tests_cpu.cpp
+8
-0
gapi_core_tests_fluid.cpp
modules/gapi/test/cpu/gapi_core_tests_fluid.cpp
+8
-0
gapi_core_tests_gpu.cpp
modules/gapi/test/gpu/gapi_core_tests_gpu.cpp
+8
-0
No files found.
modules/gapi/include/opencv2/gapi/core.hpp
View file @
576644a1
...
...
@@ -442,6 +442,12 @@ namespace core {
}
};
G_TYPED_KERNEL
(
GCopy
,
<
GMat
(
GMat
)
>
,
"org.opencv.core.transform.copy"
)
{
static
GMatDesc
outMeta
(
GMatDesc
in
)
{
return
in
;
}
};
G_TYPED_KERNEL
(
GConcatHor
,
<
GMat
(
GMat
,
GMat
)
>
,
"org.opencv.imgproc.transform.concatHor"
)
{
static
GMatDesc
outMeta
(
GMatDesc
l
,
GMatDesc
r
)
{
return
l
.
withSizeDelta
(
+
r
.
size
.
width
,
0
);
...
...
@@ -1499,6 +1505,19 @@ Output matrix must be of the same depth as input one, size is specified by given
*/
GAPI_EXPORTS
GMat
crop
(
const
GMat
&
src
,
const
Rect
&
rect
);
/** @brief Copies a 2D matrix.
The function copies the matrix.
Output matrix must be of the same size and depth as input one.
@note Function textual ID is "org.opencv.core.transform.copy"
@param src input matrix.
@sa crop
*/
GAPI_EXPORTS
GMat
copy
(
const
GMat
&
src
);
/** @brief Applies horizontal concatenation to given matrices.
The function horizontally concatenates two GMat matrices (with the same number of rows).
...
...
modules/gapi/perf/common/gapi_core_perf_tests.hpp
View file @
576644a1
...
...
@@ -64,6 +64,7 @@ namespace opencv_test
class
RemapPerfTest
:
public
TestPerfParams
<
tuple
<
cv
::
Size
,
MatType
,
cv
::
GCompileArgs
>>
{};
class
FlipPerfTest
:
public
TestPerfParams
<
tuple
<
cv
::
Size
,
MatType
,
int
,
cv
::
GCompileArgs
>>
{};
class
CropPerfTest
:
public
TestPerfParams
<
tuple
<
cv
::
Size
,
MatType
,
cv
::
Rect
,
cv
::
GCompileArgs
>>
{};
class
CopyPerfTest
:
public
TestPerfParams
<
tuple
<
cv
::
Size
,
MatType
,
cv
::
GCompileArgs
>>
{};
class
ConcatHorPerfTest
:
public
TestPerfParams
<
tuple
<
cv
::
Size
,
MatType
,
cv
::
GCompileArgs
>>
{};
class
ConcatHorVecPerfTest
:
public
TestPerfParams
<
tuple
<
cv
::
Size
,
MatType
,
cv
::
GCompileArgs
>>
{};
class
ConcatVertPerfTest
:
public
TestPerfParams
<
tuple
<
cv
::
Size
,
MatType
,
cv
::
GCompileArgs
>>
{};
...
...
modules/gapi/perf/common/gapi_core_perf_tests_inl.hpp
View file @
576644a1
...
...
@@ -1440,6 +1440,40 @@ PERF_TEST_P_(CropPerfTest, TestPerformance)
//------------------------------------------------------------------------------
PERF_TEST_P_
(
CopyPerfTest
,
TestPerformance
)
{
cv
::
Size
sz_in
=
get
<
0
>
(
GetParam
());
MatType
type
=
get
<
1
>
(
GetParam
());
cv
::
GCompileArgs
compile_args
=
get
<
2
>
(
GetParam
());
initMatrixRandU
(
type
,
sz_in
,
type
,
false
);
cv
::
Size
sz_out
=
sz_in
;
// OpenCV code ///////////////////////////////////////////////////////////
cv
::
Mat
(
in_mat1
).
copyTo
(
out_mat_ocv
);
// G-API code ////////////////////////////////////////////////////////////
cv
::
GMat
in
;
auto
out
=
cv
::
gapi
::
copy
(
in
);
cv
::
GComputation
c
(
in
,
out
);
// Warm-up graph engine:
c
.
apply
(
in_mat1
,
out_mat_gapi
,
std
::
move
(
compile_args
));
TEST_CYCLE
()
{
c
.
apply
(
in_mat1
,
out_mat_gapi
,
std
::
move
(
compile_args
));
}
// Comparison ////////////////////////////////////////////////////////////
EXPECT_EQ
(
0
,
cv
::
norm
(
out_mat_ocv
,
out_mat_gapi
,
NORM_INF
));
EXPECT_EQ
(
out_mat_gapi
.
size
(),
sz_out
);
SANITY_CHECK_NOTHING
();
}
//------------------------------------------------------------------------------
PERF_TEST_P_
(
ConcatHorPerfTest
,
TestPerformance
)
{
cv
::
Size
sz_out
=
get
<
0
>
(
GetParam
());
...
...
modules/gapi/perf/cpu/gapi_core_perf_tests_cpu.cpp
View file @
576644a1
...
...
@@ -227,6 +227,11 @@ INSTANTIATE_TEST_CASE_P(CropPerfTestCPU, CropPerfTest,
Values
(
cv
::
Rect
(
10
,
8
,
20
,
35
),
cv
::
Rect
(
4
,
10
,
37
,
50
)),
Values
(
cv
::
compile_args
(
CORE_CPU
))));
INSTANTIATE_TEST_CASE_P
(
CopyPerfTestCPU
,
CopyPerfTest
,
Combine
(
Values
(
szSmall128
,
szVGA
,
sz720p
,
sz1080p
),
Values
(
CV_8UC1
,
CV_8UC3
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
),
Values
(
cv
::
compile_args
(
CORE_CPU
))));
INSTANTIATE_TEST_CASE_P
(
ConcatHorPerfTestCPU
,
ConcatHorPerfTest
,
Combine
(
Values
(
szSmall128
,
szVGA
,
sz720p
,
sz1080p
),
Values
(
CV_8UC1
,
CV_8UC3
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
),
...
...
modules/gapi/perf/gpu/gapi_core_perf_tests_gpu.cpp
View file @
576644a1
...
...
@@ -226,6 +226,11 @@ INSTANTIATE_TEST_CASE_P(CropPerfTestGPU, CropPerfTest,
Values
(
cv
::
Rect
(
10
,
8
,
20
,
35
),
cv
::
Rect
(
4
,
10
,
37
,
50
)),
Values
(
cv
::
compile_args
(
CORE_GPU
))));
INSTANTIATE_TEST_CASE_P
(
CopyPerfTestGPU
,
CopyPerfTest
,
Combine
(
Values
(
szSmall128
,
szVGA
,
sz720p
,
sz1080p
),
Values
(
CV_8UC1
,
CV_8UC3
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
),
Values
(
cv
::
compile_args
(
CORE_GPU
))));
INSTANTIATE_TEST_CASE_P
(
ConcatHorPerfTestGPU
,
ConcatHorPerfTest
,
Combine
(
Values
(
szSmall128
,
szVGA
,
sz720p
,
sz1080p
),
Values
(
CV_8UC1
,
CV_8UC3
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
),
...
...
modules/gapi/src/api/kernels_core.cpp
View file @
576644a1
...
...
@@ -323,6 +323,11 @@ GMat crop(const GMat& src, const Rect& rect)
return
core
::
GCrop
::
on
(
src
,
rect
);
}
GMat
copy
(
const
GMat
&
src
)
{
return
core
::
GCopy
::
on
(
src
);
}
GMat
concatHor
(
const
GMat
&
src1
,
const
GMat
&
src2
)
{
return
core
::
GConcatHor
::
on
(
src1
,
src2
);
...
...
modules/gapi/src/backends/cpu/gcpucore.cpp
View file @
576644a1
...
...
@@ -501,6 +501,14 @@ GAPI_OCV_KERNEL(GCPUCrop, cv::gapi::core::GCrop)
}
};
GAPI_OCV_KERNEL
(
GCPUCopy
,
cv
::
gapi
::
core
::
GCopy
)
{
static
void
run
(
const
cv
::
Mat
&
in
,
cv
::
Mat
&
out
)
{
cv
::
Mat
(
in
).
copyTo
(
out
);
}
};
GAPI_OCV_KERNEL
(
GCPUConcatHor
,
cv
::
gapi
::
core
::
GConcatHor
)
{
static
void
run
(
const
cv
::
Mat
&
in1
,
const
cv
::
Mat
&
in2
,
cv
::
Mat
&
out
)
...
...
@@ -611,6 +619,7 @@ cv::gapi::GKernelPackage cv::gapi::core::cpu::kernels()
,
GCPURemap
,
GCPUFlip
,
GCPUCrop
,
GCPUCopy
,
GCPUConcatHor
,
GCPUConcatVert
,
GCPULUT
...
...
modules/gapi/src/backends/fluid/gfluidcore.cpp
View file @
576644a1
...
...
@@ -2118,6 +2118,40 @@ GAPI_FLUID_KERNEL(GFluidSqrt, cv::gapi::core::GSqrt, false)
}
};
GAPI_FLUID_KERNEL
(
GFluidCopy
,
cv
::
gapi
::
core
::
GCopy
,
false
)
{
static
const
int
Window
=
1
;
static
void
run
(
const
View
&
src
,
Buffer
&
dst
)
{
const
auto
*
in
=
src
.
InLine
<
uchar
>
(
0
);
auto
*
out
=
dst
.
OutLine
<
uchar
>
();
GAPI_DbgAssert
(
dst
.
length
()
==
src
.
length
());
GAPI_DbgAssert
(
dst
.
meta
().
chan
==
src
.
meta
().
chan
);
GAPI_DbgAssert
(
dst
.
meta
().
depth
==
src
.
meta
().
depth
);
int
width
=
src
.
length
();
int
elem_size
=
CV_ELEM_SIZE
(
CV_MAKETYPE
(
src
.
meta
().
depth
,
src
.
meta
().
chan
));
int
w
=
0
;
// cycle counter
#if CV_SIMD128
for
(;
w
<=
width
*
elem_size
-
16
;
w
+=
16
)
{
v_uint8x16
a
;
a
=
v_load
(
&
in
[
w
]);
v_store
(
&
out
[
w
],
a
);
}
#endif
for
(;
w
<
width
*
elem_size
;
w
++
)
{
out
[
w
]
=
in
[
w
];
}
}
};
}
// namespace fliud
}
// namespace gapi
}
// namespace cv
...
...
@@ -2173,6 +2207,7 @@ cv::gapi::GKernelPackage cv::gapi::core::fluid::kernels()
,
GFluidInRange
,
GFluidResize
,
GFluidSqrt
,
GFluidCopy
#if 0
,GFluidMean -- not fluid
,GFluidSum -- not fluid
...
...
modules/gapi/src/backends/ocl/goclcore.cpp
View file @
576644a1
...
...
@@ -482,6 +482,14 @@ GAPI_OCL_KERNEL(GOCLCrop, cv::gapi::core::GCrop)
}
};
GAPI_OCL_KERNEL
(
GOCLCopy
,
cv
::
gapi
::
core
::
GCopy
)
{
static
void
run
(
const
cv
::
UMat
&
in
,
cv
::
UMat
&
out
)
{
cv
::
UMat
(
in
).
copyTo
(
out
);
}
};
GAPI_OCL_KERNEL
(
GOCLConcatHor
,
cv
::
gapi
::
core
::
GConcatHor
)
{
static
void
run
(
const
cv
::
UMat
&
in1
,
const
cv
::
UMat
&
in2
,
cv
::
UMat
&
out
)
...
...
@@ -573,6 +581,7 @@ cv::gapi::GKernelPackage cv::gapi::core::ocl::kernels()
,
GOCLRemap
,
GOCLFlip
,
GOCLCrop
,
GOCLCopy
,
GOCLConcatHor
,
GOCLConcatVert
,
GOCLLUT
...
...
modules/gapi/test/common/gapi_core_tests.hpp
View file @
576644a1
...
...
@@ -100,6 +100,7 @@ GAPI_TEST_FIXTURE(Merge4Test, initMatsRandU, <>, 0)
GAPI_TEST_FIXTURE
(
RemapTest
,
initMatrixRandU
,
<>
,
0
)
GAPI_TEST_FIXTURE
(
FlipTest
,
initMatrixRandU
,
FIXTURE_API
(
int
),
1
,
flipCode
)
GAPI_TEST_FIXTURE
(
CropTest
,
initMatrixRandU
,
FIXTURE_API
(
cv
::
Rect
),
1
,
rect_to
)
GAPI_TEST_FIXTURE
(
CopyTest
,
initMatrixRandU
,
<>
,
0
)
GAPI_TEST_FIXTURE
(
ConcatHorTest
,
initNothing
,
<>
,
0
)
GAPI_TEST_FIXTURE
(
ConcatVertTest
,
initNothing
,
<>
,
0
)
GAPI_TEST_FIXTURE
(
ConcatVertVecTest
,
initNothing
,
<>
,
0
)
...
...
modules/gapi/test/common/gapi_core_tests_inl.hpp
View file @
576644a1
...
...
@@ -1002,6 +1002,32 @@ TEST_P(CropTest, AccuracyTest)
}
}
TEST_P
(
CopyTest
,
AccuracyTest
)
{
cv
::
Size
sz_out
=
sz
;
if
(
dtype
!=
-
1
)
{
out_mat_gapi
=
cv
::
Mat
(
sz_out
,
dtype
);
out_mat_ocv
=
cv
::
Mat
(
sz_out
,
dtype
);
}
// G-API code //////////////////////////////////////////////////////////////
cv
::
GMat
in
;
auto
out
=
cv
::
gapi
::
copy
(
in
);
cv
::
GComputation
c
(
in
,
out
);
c
.
apply
(
in_mat1
,
out_mat_gapi
,
getCompileArgs
());
// OpenCV code /////////////////////////////////////////////////////////////
{
cv
::
Mat
(
in_mat1
).
copyTo
(
out_mat_ocv
);
}
// Comparison //////////////////////////////////////////////////////////////
{
EXPECT_EQ
(
0
,
cv
::
countNonZero
(
out_mat_ocv
!=
out_mat_gapi
));
EXPECT_EQ
(
out_mat_gapi
.
size
(),
sz_out
);
}
}
TEST_P
(
ConcatHorTest
,
AccuracyTest
)
{
cv
::
Size
sz_out
=
sz
;
...
...
modules/gapi/test/cpu/gapi_core_tests_cpu.cpp
View file @
576644a1
...
...
@@ -365,6 +365,14 @@ INSTANTIATE_TEST_CASE_P(CropTestCPU, CropTest,
Values
(
CORE_CPU
),
Values
(
cv
::
Rect
(
10
,
8
,
20
,
35
),
cv
::
Rect
(
4
,
10
,
37
,
50
))));
INSTANTIATE_TEST_CASE_P
(
CopyTestCPU
,
CopyTest
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
),
Values
(
cv
::
Size
(
1280
,
720
),
cv
::
Size
(
640
,
480
),
cv
::
Size
(
128
,
128
)),
Values
(
-
1
),
Values
(
CORE_CPU
)));
INSTANTIATE_TEST_CASE_P
(
LUTTestCPU
,
LUTTest
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
),
Values
(
cv
::
Size
(
1280
,
720
),
...
...
modules/gapi/test/cpu/gapi_core_tests_fluid.cpp
View file @
576644a1
...
...
@@ -275,6 +275,14 @@ INSTANTIATE_TEST_CASE_P(ReInitOutTestFluid, ReInitOutTest,
Values
(
cv
::
Size
(
640
,
400
),
cv
::
Size
(
10
,
480
))));
INSTANTIATE_TEST_CASE_P
(
CopyTestFluid
,
CopyTest
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
),
Values
(
cv
::
Size
(
1280
,
720
),
cv
::
Size
(
640
,
480
),
cv
::
Size
(
128
,
128
)),
Values
(
-
1
),
Values
(
CORE_FLUID
)));
//----------------------------------------------------------------------
// FIXME: Clean-up test configurations which are enabled already
#if 0
...
...
modules/gapi/test/gpu/gapi_core_tests_gpu.cpp
View file @
576644a1
...
...
@@ -336,6 +336,14 @@ INSTANTIATE_TEST_CASE_P(CropTestGPU, CropTest,
Values
(
CORE_GPU
),
Values
(
cv
::
Rect
(
10
,
8
,
20
,
35
),
cv
::
Rect
(
4
,
10
,
37
,
50
))));
INSTANTIATE_TEST_CASE_P
(
CopyTestGPU
,
CopyTest
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
),
Values
(
cv
::
Size
(
1280
,
720
),
cv
::
Size
(
640
,
480
),
cv
::
Size
(
128
,
128
)),
Values
(
-
1
),
Values
(
CORE_GPU
)));
INSTANTIATE_TEST_CASE_P
(
LUTTestGPU
,
LUTTest
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
),
Values
(
cv
::
Size
(
1280
,
720
),
...
...
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