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
e623e710
Commit
e623e710
authored
8 years ago
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7597 from terfendail:ovx_threshold
parents
32f48a8d
0cd37886
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
0 deletions
+125
-0
ivx.hpp
3rdparty/openvx/include/ivx.hpp
+20
-0
thresh.cpp
modules/imgproc/src/thresh.cpp
+105
-0
No files found.
3rdparty/openvx/include/ivx.hpp
View file @
e623e710
...
...
@@ -1823,6 +1823,26 @@ static const vx_enum
query
(
VX_THRESHOLD_FALSE_VALUE
,
v
);
return
v
;
}
/// vxSetThresholdAttribute(THRESHOLD_VALUE) wrapper
void
setValue
(
vx_int32
&
val
)
{
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
ref
,
VX_THRESHOLD_THRESHOLD_VALUE
,
&
val
,
sizeof
(
val
)));
}
/// vxSetThresholdAttribute(THRESHOLD_LOWER) wrapper
void
setValueLower
(
vx_int32
&
val
)
{
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
ref
,
VX_THRESHOLD_THRESHOLD_LOWER
,
&
val
,
sizeof
(
val
)));
}
/// vxSetThresholdAttribute(THRESHOLD_UPPER) wrapper
void
setValueUpper
(
vx_int32
&
val
)
{
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
ref
,
VX_THRESHOLD_THRESHOLD_UPPER
,
&
val
,
sizeof
(
val
)));
}
/// vxSetThresholdAttribute(TRUE_VALUE) wrapper
void
setValueTrue
(
vx_int32
&
val
)
{
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
ref
,
VX_THRESHOLD_TRUE_VALUE
,
&
val
,
sizeof
(
val
)));
}
/// vxSetThresholdAttribute(FALSE_VALUE) wrapper
void
setValueFalse
(
vx_int32
&
val
)
{
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
ref
,
VX_THRESHOLD_FALSE_VALUE
,
&
val
,
sizeof
(
val
)));
}
};
/// vx_array wrapper
...
...
This diff is collapsed.
Click to expand it.
modules/imgproc/src/thresh.cpp
View file @
e623e710
...
...
@@ -44,6 +44,12 @@
#include "opencl_kernels_imgproc.hpp"
#include "opencv2/core/hal/intrin.hpp"
#ifdef HAVE_OPENVX
#define IVX_HIDE_INFO_WARNINGS
#define IVX_USE_OPENCV
#include "ivx.hpp"
#endif
namespace
cv
{
...
...
@@ -1244,6 +1250,99 @@ static bool ocl_threshold( InputArray _src, OutputArray _dst, double & thresh, d
#endif
#ifdef HAVE_OPENVX
#define IMPL_OPENVX_TOZERO 1
static
bool
openvx_threshold
(
Mat
src
,
Mat
dst
,
int
thresh
,
int
maxval
,
int
type
)
{
Mat
a
=
src
;
int
trueVal
,
falseVal
;
switch
(
type
)
{
case
THRESH_BINARY
:
#ifndef VX_VERSION_1_1
if
(
maxval
!=
255
)
return
false
;
#endif
trueVal
=
maxval
;
falseVal
=
0
;
break
;
case
THRESH_TOZERO
:
#if IMPL_OPENVX_TOZERO
trueVal
=
255
;
falseVal
=
0
;
if
(
dst
.
data
==
src
.
data
)
{
a
=
Mat
(
src
.
size
(),
src
.
type
());
src
.
copyTo
(
a
);
}
break
;
#endif
case
THRESH_BINARY_INV
:
#ifdef VX_VERSION_1_1
trueVal
=
0
;
falseVal
=
maxval
;
break
;
#endif
case
THRESH_TOZERO_INV
:
#ifdef VX_VERSION_1_1
#if IMPL_OPENVX_TOZERO
trueVal
=
0
;
falseVal
=
255
;
if
(
dst
.
data
==
src
.
data
)
{
a
=
Mat
(
src
.
size
(),
src
.
type
());
src
.
copyTo
(
a
);
}
break
;
#endif
#endif
case
THRESH_TRUNC
:
default:
return
false
;
}
try
{
ivx
::
Context
ctx
=
ivx
::
Context
::
create
();
ivx
::
Threshold
thh
=
ivx
::
Threshold
::
createBinary
(
ctx
,
VX_TYPE_UINT8
,
thresh
);
thh
.
setValueTrue
(
trueVal
);
thh
.
setValueFalse
(
falseVal
);
ivx
::
Image
ia
=
ivx
::
Image
::
createFromHandle
(
ctx
,
VX_DF_IMAGE_U8
,
ivx
::
Image
::
createAddressing
(
a
.
cols
*
a
.
channels
(),
a
.
rows
,
1
,
(
vx_int32
)(
a
.
step
)),
src
.
data
),
ib
=
ivx
::
Image
::
createFromHandle
(
ctx
,
VX_DF_IMAGE_U8
,
ivx
::
Image
::
createAddressing
(
dst
.
cols
*
dst
.
channels
(),
dst
.
rows
,
1
,
(
vx_int32
)(
dst
.
step
)),
dst
.
data
);
ivx
::
IVX_CHECK_STATUS
(
vxuThreshold
(
ctx
,
ia
,
thh
,
ib
));
#if IMPL_OPENVX_TOZERO
if
(
type
==
THRESH_TOZERO
||
type
==
THRESH_TOZERO_INV
)
{
ivx
::
Image
ic
=
ivx
::
Image
::
createFromHandle
(
ctx
,
VX_DF_IMAGE_U8
,
ivx
::
Image
::
createAddressing
(
dst
.
cols
*
dst
.
channels
(),
dst
.
rows
,
1
,
(
vx_int32
)(
dst
.
step
)),
dst
.
data
);
ivx
::
IVX_CHECK_STATUS
(
vxuAnd
(
ctx
,
ib
,
ia
,
ic
));
}
#endif
}
catch
(
ivx
::
RuntimeError
&
e
)
{
CV_Error
(
CV_StsInternal
,
e
.
what
());
return
false
;
}
catch
(
ivx
::
WrapperError
&
e
)
{
CV_Error
(
CV_StsInternal
,
e
.
what
());
return
false
;
}
return
true
;
}
#endif
}
double
cv
::
threshold
(
InputArray
_src
,
OutputArray
_dst
,
double
thresh
,
double
maxval
,
int
type
)
...
...
@@ -1296,6 +1395,12 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
src
.
copyTo
(
dst
);
return
thresh
;
}
#ifdef HAVE_OPENVX
if
(
openvx_threshold
(
src
,
dst
,
ithresh
,
imaxval
,
type
))
return
thresh
;
#endif
thresh
=
ithresh
;
maxval
=
imaxval
;
}
...
...
This diff is collapsed.
Click to expand it.
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