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
b5426a86
Commit
b5426a86
authored
Nov 13, 2019
by
Anton Potapov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
G-API (Fluid) core support for I420
- Extended NV12 support in Fluid Core engine to cover I420
parent
b6a58818
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
18 deletions
+19
-18
gfluidkernel.hpp
modules/gapi/include/opencv2/gapi/fluid/gfluidkernel.hpp
+1
-1
gfluidbackend.cpp
modules/gapi/src/backends/fluid/gfluidbackend.cpp
+17
-16
gapi_fluid_test_kernels.cpp
modules/gapi/test/gapi_fluid_test_kernels.cpp
+1
-1
No files found.
modules/gapi/include/opencv2/gapi/fluid/gfluidkernel.hpp
View file @
b5426a86
...
@@ -50,7 +50,7 @@ public:
...
@@ -50,7 +50,7 @@ public:
{
{
Filter
,
Filter
,
Resize
,
Resize
,
NV12to
RGB
YUV420toRGB
//Color conversion of 4:2:0 chroma sub-sampling formats (NV12, I420 ..etc) to
RGB
};
};
// This function is a generic "doWork" callback
// This function is a generic "doWork" callback
...
...
modules/gapi/src/backends/fluid/gfluidbackend.cpp
View file @
b5426a86
...
@@ -198,7 +198,7 @@ public:
...
@@ -198,7 +198,7 @@ public:
using
FluidAgent
::
FluidAgent
;
using
FluidAgent
::
FluidAgent
;
};
};
struct
Fluid
NV12
toRGBAgent
:
public
FluidAgent
struct
Fluid
420
toRGBAgent
:
public
FluidAgent
{
{
private
:
private
:
virtual
int
firstWindow
(
std
::
size_t
inPort
)
const
override
;
virtual
int
firstWindow
(
std
::
size_t
inPort
)
const
override
;
...
@@ -313,7 +313,7 @@ static int maxLineConsumption(const cv::GFluidKernel::Kind kind, int window, int
...
@@ -313,7 +313,7 @@ static int maxLineConsumption(const cv::GFluidKernel::Kind kind, int window, int
return
(
inH
==
1
)
?
1
:
2
+
lpi
-
1
;
return
(
inH
==
1
)
?
1
:
2
+
lpi
-
1
;
}
}
}
break
;
}
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
NV12
toRGB
:
return
inPort
==
0
?
2
:
1
;
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
YUV420
toRGB
:
return
inPort
==
0
?
2
:
1
;
break
;
default
:
GAPI_Assert
(
false
);
return
0
;
default
:
GAPI_Assert
(
false
);
return
0
;
}
}
}
}
...
@@ -325,7 +325,7 @@ static int borderSize(const cv::GFluidKernel::Kind kind, int window)
...
@@ -325,7 +325,7 @@ static int borderSize(const cv::GFluidKernel::Kind kind, int window)
case
cv
:
:
GFluidKernel
::
Kind
::
Filter
:
return
(
window
-
1
)
/
2
;
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
Filter
:
return
(
window
-
1
)
/
2
;
break
;
// Resize never reads from border pixels
// Resize never reads from border pixels
case
cv
:
:
GFluidKernel
::
Kind
::
Resize
:
return
0
;
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
Resize
:
return
0
;
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
NV12
toRGB
:
return
0
;
break
;
case
cv
:
:
GFluidKernel
::
Kind
::
YUV420
toRGB
:
return
0
;
break
;
default
:
GAPI_Assert
(
false
);
return
0
;
default
:
GAPI_Assert
(
false
);
return
0
;
}
}
}
}
...
@@ -435,13 +435,13 @@ std::pair<int,int> cv::gimpl::FluidResizeAgent::linesReadAndnextWindow(std::size
...
@@ -435,13 +435,13 @@ std::pair<int,int> cv::gimpl::FluidResizeAgent::linesReadAndnextWindow(std::size
return
m_mapper
->
linesReadAndNextWindow
(
outIdx
,
lpi
);
return
m_mapper
->
linesReadAndNextWindow
(
outIdx
,
lpi
);
}
}
int
cv
::
gimpl
::
Fluid
NV12
toRGBAgent
::
firstWindow
(
std
::
size_t
inPort
)
const
int
cv
::
gimpl
::
Fluid
420
toRGBAgent
::
firstWindow
(
std
::
size_t
inPort
)
const
{
{
// 2 lines for Y, 1 for UV
// 2 lines for Y, 1 for UV
return
inPort
==
0
?
2
:
1
;
return
inPort
==
0
?
2
:
1
;
}
}
std
::
pair
<
int
,
int
>
cv
::
gimpl
::
Fluid
NV12
toRGBAgent
::
linesReadAndnextWindow
(
std
::
size_t
inPort
)
const
std
::
pair
<
int
,
int
>
cv
::
gimpl
::
Fluid
420
toRGBAgent
::
linesReadAndnextWindow
(
std
::
size_t
inPort
)
const
{
{
// 2 lines for Y, 1 for UV
// 2 lines for Y, 1 for UV
return
inPort
==
0
?
std
::
make_pair
(
2
,
2
)
:
std
::
make_pair
(
1
,
1
);
return
inPort
==
0
?
std
::
make_pair
(
2
,
2
)
:
std
::
make_pair
(
1
,
1
);
...
@@ -675,7 +675,7 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
...
@@ -675,7 +675,7 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
return
roi
;
return
roi
;
};
};
auto
adj
NV12
Roi
=
[
&
](
cv
::
gapi
::
own
::
Rect
produced
,
std
::
size_t
port
)
{
auto
adj
420
Roi
=
[
&
](
cv
::
gapi
::
own
::
Rect
produced
,
std
::
size_t
port
)
{
GAPI_Assert
(
produced
.
x
%
2
==
0
);
GAPI_Assert
(
produced
.
x
%
2
==
0
);
GAPI_Assert
(
produced
.
y
%
2
==
0
);
GAPI_Assert
(
produced
.
y
%
2
==
0
);
GAPI_Assert
(
produced
.
width
%
2
==
0
);
GAPI_Assert
(
produced
.
width
%
2
==
0
);
...
@@ -684,7 +684,8 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
...
@@ -684,7 +684,8 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
cv
::
gapi
::
own
::
Rect
roi
;
cv
::
gapi
::
own
::
Rect
roi
;
switch
(
port
)
{
switch
(
port
)
{
case
0
:
roi
=
produced
;
break
;
case
0
:
roi
=
produced
;
break
;
case
1
:
roi
=
cv
::
gapi
::
own
::
Rect
{
produced
.
x
/
2
,
produced
.
y
/
2
,
produced
.
width
/
2
,
produced
.
height
/
2
};
break
;
case
1
:
case
2
:
roi
=
cv
::
gapi
::
own
::
Rect
{
produced
.
x
/
2
,
produced
.
y
/
2
,
produced
.
width
/
2
,
produced
.
height
/
2
};
break
;
default
:
GAPI_Assert
(
false
);
default
:
GAPI_Assert
(
false
);
}
}
return
roi
;
return
roi
;
...
@@ -696,19 +697,19 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
...
@@ -696,19 +697,19 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
cv
::
gapi
::
own
::
Rect
resized
;
cv
::
gapi
::
own
::
Rect
resized
;
switch
(
fg
.
metadata
(
oh
).
get
<
FluidUnit
>
().
k
.
m_kind
)
switch
(
fg
.
metadata
(
oh
).
get
<
FluidUnit
>
().
k
.
m_kind
)
{
{
case
GFluidKernel
:
:
Kind
::
Filter
:
resized
=
produced
;
break
;
case
GFluidKernel
:
:
Kind
::
Filter
:
resized
=
produced
;
break
;
case
GFluidKernel
:
:
Kind
::
Resize
:
resized
=
adjResizeRoi
(
produced
,
in_meta
.
size
,
meta
.
size
);
break
;
case
GFluidKernel
:
:
Kind
::
Resize
:
resized
=
adjResizeRoi
(
produced
,
in_meta
.
size
,
meta
.
size
);
break
;
case
GFluidKernel
:
:
Kind
::
NV12toRGB
:
resized
=
adjNV12
Roi
(
produced
,
m_gm
.
metadata
(
in_edge
).
get
<
Input
>
().
port
);
break
;
case
GFluidKernel
:
:
Kind
::
YUV420toRGB
:
resized
=
adj420
Roi
(
produced
,
m_gm
.
metadata
(
in_edge
).
get
<
Input
>
().
port
);
break
;
default
:
GAPI_Assert
(
false
);
default
:
GAPI_Assert
(
false
);
}
}
// All below transformations affect roi of the writer, preserve read start position here
// All below transformations affect roi of the writer, preserve read start position here
int
readStart
=
resized
.
y
;
int
readStart
=
resized
.
y
;
// Extend required input roi (both y and height) to be even if it's produced by
NV12
toRGB
// Extend required input roi (both y and height) to be even if it's produced by
CS420
toRGB
if
(
!
in_node
->
inNodes
().
empty
())
{
if
(
!
in_node
->
inNodes
().
empty
())
{
auto
in_data_producer
=
in_node
->
inNodes
().
front
();
auto
in_data_producer
=
in_node
->
inNodes
().
front
();
if
(
fg
.
metadata
(
in_data_producer
).
get
<
FluidUnit
>
().
k
.
m_kind
==
GFluidKernel
::
Kind
::
NV12
toRGB
)
{
if
(
fg
.
metadata
(
in_data_producer
).
get
<
FluidUnit
>
().
k
.
m_kind
==
GFluidKernel
::
Kind
::
YUV420
toRGB
)
{
if
(
resized
.
y
%
2
!=
0
)
{
if
(
resized
.
y
%
2
!=
0
)
{
resized
.
y
--
;
resized
.
y
--
;
resized
.
height
++
;
resized
.
height
++
;
...
@@ -840,9 +841,9 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph
...
@@ -840,9 +841,9 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph
std
::
unique_ptr
<
FluidAgent
>
agent_ptr
;
std
::
unique_ptr
<
FluidAgent
>
agent_ptr
;
switch
(
agent_data
.
kind
)
switch
(
agent_data
.
kind
)
{
{
case
GFluidKernel
:
:
Kind
::
Filter
:
agent_ptr
.
reset
(
new
FluidFilterAgent
(
g
,
agent_data
.
nh
));
break
;
case
GFluidKernel
:
:
Kind
::
Filter
:
agent_ptr
.
reset
(
new
FluidFilterAgent
(
g
,
agent_data
.
nh
));
break
;
case
GFluidKernel
:
:
Kind
::
Resize
:
agent_ptr
.
reset
(
new
FluidResizeAgent
(
g
,
agent_data
.
nh
));
break
;
case
GFluidKernel
:
:
Kind
::
Resize
:
agent_ptr
.
reset
(
new
FluidResizeAgent
(
g
,
agent_data
.
nh
));
break
;
case
GFluidKernel
:
:
Kind
::
NV12toRGB
:
agent_ptr
.
reset
(
new
FluidNV12toRGBAgent
(
g
,
agent_data
.
nh
));
break
;
case
GFluidKernel
:
:
Kind
::
YUV420toRGB
:
agent_ptr
.
reset
(
new
Fluid420toRGBAgent
(
g
,
agent_data
.
nh
));
break
;
default
:
GAPI_Assert
(
false
);
default
:
GAPI_Assert
(
false
);
}
}
std
::
tie
(
agent_ptr
->
in_buffer_ids
,
agent_ptr
->
out_buffer_ids
)
=
std
::
tie
(
agent_data
.
in_buffer_ids
,
agent_data
.
out_buffer_ids
);
std
::
tie
(
agent_ptr
->
in_buffer_ids
,
agent_ptr
->
out_buffer_ids
)
=
std
::
tie
(
agent_data
.
in_buffer_ids
,
agent_data
.
out_buffer_ids
);
...
@@ -1005,7 +1006,7 @@ namespace
...
@@ -1005,7 +1006,7 @@ namespace
GAPI_Assert
((
out_ws
.
size
()
==
1
&&
out_hs
.
size
()
==
1
)
&&
GAPI_Assert
((
out_ws
.
size
()
==
1
&&
out_hs
.
size
()
==
1
)
&&
((
in_hs
.
size
()
==
1
)
||
((
in_hs
.
size
()
==
1
)
||
((
in_hs
.
size
()
==
2
)
&&
fu
.
k
.
m_kind
==
cv
::
GFluidKernel
::
Kind
::
NV12
toRGB
)));
((
in_hs
.
size
()
==
2
)
&&
fu
.
k
.
m_kind
==
cv
::
GFluidKernel
::
Kind
::
YUV420
toRGB
)));
const
auto
&
op
=
g
.
metadata
(
node
).
get
<
Op
>
();
const
auto
&
op
=
g
.
metadata
(
node
).
get
<
Op
>
();
fu
.
line_consumption
.
resize
(
op
.
args
.
size
(),
0
);
fu
.
line_consumption
.
resize
(
op
.
args
.
size
(),
0
);
...
...
modules/gapi/test/gapi_fluid_test_kernels.cpp
View file @
b5426a86
...
@@ -530,7 +530,7 @@ GAPI_FLUID_KERNEL(FNV12toRGB, cv::gapi::imgproc::GNV12toRGB, false)
...
@@ -530,7 +530,7 @@ GAPI_FLUID_KERNEL(FNV12toRGB, cv::gapi::imgproc::GNV12toRGB, false)
{
{
static
const
int
Window
=
1
;
static
const
int
Window
=
1
;
static
const
int
LPI
=
2
;
static
const
int
LPI
=
2
;
static
const
auto
Kind
=
GFluidKernel
::
Kind
::
NV12
toRGB
;
static
const
auto
Kind
=
GFluidKernel
::
Kind
::
YUV420
toRGB
;
static
void
run
(
const
cv
::
gapi
::
fluid
::
View
&
in1
,
static
void
run
(
const
cv
::
gapi
::
fluid
::
View
&
in1
,
const
cv
::
gapi
::
fluid
::
View
&
in2
,
const
cv
::
gapi
::
fluid
::
View
&
in2
,
...
...
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