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
3f7cde04
Commit
3f7cde04
authored
Dec 12, 2016
by
Naba Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement 32f support for morphology operation
parent
2fded5d8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
7 deletions
+38
-7
filtering.cpp
modules/cudafilters/src/filtering.cpp
+38
-7
No files found.
modules/cudafilters/src/filtering.cpp
View file @
3f7cde04
...
...
@@ -525,14 +525,17 @@ namespace
void
apply
(
InputArray
src
,
OutputArray
dst
,
Stream
&
stream
=
Stream
::
Null
());
private
:
typedef
NppStatus
(
*
nppMorfFilter_t
)(
const
Npp8u
*
pSrc
,
Npp32s
nSrcStep
,
Npp8u
*
pDst
,
Npp32s
nDstStep
,
NppiSize
oSizeROI
,
typedef
NppStatus
(
*
nppMorfFilter8u_t
)(
const
Npp8u
*
pSrc
,
Npp32s
nSrcStep
,
Npp8u
*
pDst
,
Npp32s
nDstStep
,
NppiSize
oSizeROI
,
const
Npp8u
*
pMask
,
NppiSize
oMaskSize
,
NppiPoint
oAnchor
);
typedef
NppStatus
(
*
nppMorfFilter32f_t
)(
const
Npp32f
*
pSrc
,
Npp32s
nSrcStep
,
Npp32f
*
pDst
,
Npp32s
nDstStep
,
NppiSize
oSizeROI
,
const
Npp8u
*
pMask
,
NppiSize
oMaskSize
,
NppiPoint
oAnchor
);
int
type_
;
GpuMat
kernel_
;
Point
anchor_
;
int
iters_
;
nppMorfFilter_t
func_
;
nppMorfFilter8u_t
func8u_
;
nppMorfFilter32f_t
func32f_
;
GpuMat
srcBorder_
;
GpuMat
buf_
;
...
...
@@ -541,14 +544,19 @@ namespace
MorphologyFilter
::
MorphologyFilter
(
int
op
,
int
srcType
,
InputArray
_kernel
,
Point
anchor
,
int
iterations
)
:
type_
(
srcType
),
anchor_
(
anchor
),
iters_
(
iterations
)
{
static
const
nppMorfFilter
_t
funcs
[
2
][
5
]
=
static
const
nppMorfFilter
8u_t
funcs8u
[
2
][
5
]
=
{
{
0
,
nppiErode_8u_C1R
,
0
,
0
,
nppiErode_8u_C4R
},
{
0
,
nppiDilate_8u_C1R
,
0
,
0
,
nppiDilate_8u_C4R
}
};
static
const
nppMorfFilter32f_t
funcs32f
[
2
][
5
]
=
{
{
0
,
nppiErode_32f_C1R
,
0
,
0
,
nppiErode_32f_C4R
},
{
0
,
nppiDilate_32f_C1R
,
0
,
0
,
nppiDilate_32f_C4R
}
};
CV_Assert
(
op
==
MORPH_ERODE
||
op
==
MORPH_DILATE
);
CV_Assert
(
srcType
==
CV_8UC1
||
srcType
==
CV_8UC4
);
CV_Assert
(
srcType
==
CV_8UC1
||
srcType
==
CV_8UC4
||
srcType
==
CV_32FC1
||
srcType
==
CV_32FC4
);
Mat
kernel
=
_kernel
.
getMat
();
Size
ksize
=
!
kernel
.
empty
()
?
_kernel
.
size
()
:
Size
(
3
,
3
);
...
...
@@ -579,7 +587,14 @@ namespace
kernel_
=
cuda
::
createContinuous
(
kernel
.
size
(),
CV_8UC1
);
kernel_
.
upload
(
kernel8U
);
func_
=
funcs
[
op
][
CV_MAT_CN
(
srcType
)];
if
(
srcType
==
CV_8UC1
||
srcType
==
CV_8UC4
)
{
func8u_
=
funcs8u
[
op
][
CV_MAT_CN
(
srcType
)];
}
else
if
(
srcType
==
CV_32FC1
||
srcType
==
CV_32FC4
)
{
func32f_
=
funcs32f
[
op
][
CV_MAT_CN
(
srcType
)];
}
}
void
MorphologyFilter
::
apply
(
InputArray
_src
,
OutputArray
_dst
,
Stream
&
_stream
)
...
...
@@ -618,16 +633,32 @@ namespace
oAnchor
.
x
=
anchor_
.
x
;
oAnchor
.
y
=
anchor_
.
y
;
nppSafeCall
(
func_
(
srcRoi
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
srcRoi
.
step
),
dst
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
dst
.
step
),
if
(
type_
==
CV_8UC1
||
type_
==
CV_8UC4
)
{
nppSafeCall
(
func8u_
(
srcRoi
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
srcRoi
.
step
),
dst
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
,
kernel_
.
ptr
<
Npp8u
>
(),
oMaskSize
,
oAnchor
)
);
for
(
int
i
=
1
;
i
<
iters_
;
++
i
)
{
dst
.
copyTo
(
bufRoi
,
_stream
);
nppSafeCall
(
func
_
(
bufRoi
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
bufRoi
.
step
),
dst
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
dst
.
step
),
nppSafeCall
(
func8u
_
(
bufRoi
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
bufRoi
.
step
),
dst
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
,
kernel_
.
ptr
<
Npp8u
>
(),
oMaskSize
,
oAnchor
)
);
}
}
else
if
(
type_
==
CV_32FC1
||
type_
==
CV_32FC4
)
{
nppSafeCall
(
func32f_
(
srcRoi
.
ptr
<
Npp32f
>
(),
static_cast
<
int
>
(
srcRoi
.
step
),
dst
.
ptr
<
Npp32f
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
,
kernel_
.
ptr
<
Npp8u
>
(),
oMaskSize
,
oAnchor
)
);
for
(
int
i
=
1
;
i
<
iters_
;
++
i
)
{
dst
.
copyTo
(
bufRoi
,
_stream
);
nppSafeCall
(
func32f_
(
bufRoi
.
ptr
<
Npp32f
>
(),
static_cast
<
int
>
(
bufRoi
.
step
),
dst
.
ptr
<
Npp32f
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
,
kernel_
.
ptr
<
Npp8u
>
(),
oMaskSize
,
oAnchor
)
);
}
}
if
(
stream
==
0
)
cudaSafeCall
(
cudaDeviceSynchronize
()
);
...
...
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