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
1e2ddc30
Commit
1e2ddc30
authored
Nov 25, 2016
by
apavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Canny via OpenVX, Node wrapper extended (query/set attribute), some naming fixes
parent
beea04cc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
219 additions
and
7 deletions
+219
-7
ivx.hpp
3rdparty/openvx/include/ivx.hpp
+0
-0
core.hpp
modules/core/include/opencv2/core.hpp
+1
-0
ovx_defs.hpp
modules/core/include/opencv2/core/openvx/ovx_defs.hpp
+33
-0
ovx.hpp
modules/core/include/opencv2/core/ovx.hpp
+28
-0
ovx.cpp
modules/core/src/ovx.cpp
+72
-0
precomp.hpp
modules/core/src/precomp.hpp
+8
-3
canny.cpp
modules/imgproc/src/canny.cpp
+73
-0
deriv.cpp
modules/imgproc/src/deriv.cpp
+4
-4
No files found.
3rdparty/openvx/include/ivx.hpp
View file @
1e2ddc30
This diff is collapsed.
Click to expand it.
modules/core/include/opencv2/core.hpp
View file @
1e2ddc30
...
...
@@ -3215,5 +3215,6 @@ template<> struct ParamType<uchar>
#include "opencv2/core/cvstd.inl.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/optim.hpp"
#include "opencv2/core/ovx.hpp"
#endif
/*OPENCV_CORE_HPP*/
modules/core/include/opencv2/core/openvx/ovx_defs.hpp
0 → 100644
View file @
1e2ddc30
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2016, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
// OpenVX related definitions and declarations
#pragma once
#ifndef OPENCV_OVX_DEFS_HPP
#define OPENCV_OVX_DEFS_HPP
#include "cvconfig.h"
// utility macro for running OpenVX-based implementations
#ifdef HAVE_OPENVX
#define IVX_HIDE_INFO_WARNINGS
#define IVX_USE_OPENCV
#include "ivx.hpp"
#define CV_OVX_RUN(condition, func, ...) \
if (cv::useOpenVX() && (condition) && func) \
{ \
return __VA_ARGS__; \
}
#else
#define CV_OVX_RUN(condition, func, ...)
#endif // HAVE_OPENVX
#endif // OPENCV_OVX_DEFS_HPP
modules/core/include/opencv2/core/ovx.hpp
0 → 100644
View file @
1e2ddc30
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2016, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
// OpenVX related definitions and declarations
#pragma once
#ifndef OPENCV_OVX_HPP
#define OPENCV_OVX_HPP
#include "cvdef.h"
namespace
cv
{
/// Check if use of OpenVX is possible
CV_EXPORTS_W
bool
haveOpenVX
();
/// Check if use of OpenVX is enabled
CV_EXPORTS_W
bool
useOpenVX
();
/// Enable/disable use of OpenVX
CV_EXPORTS_W
void
setUseOpenVX
(
bool
flag
);
}
// namespace cv
#endif // OPENCV_OVX_HPP
modules/core/src/ovx.cpp
0 → 100644
View file @
1e2ddc30
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2016, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
// OpenVX related functions
#include "precomp.hpp"
#include "opencv2/core/ovx.hpp"
#include "opencv2/core/openvx/ovx_defs.hpp"
namespace
cv
{
bool
haveOpenVX
()
{
#ifdef HAVE_OPENVX
static
int
g_haveOpenVX
=
-
1
;
if
(
g_haveOpenVX
<
0
)
{
try
{
ivx
::
Context
context
=
ivx
::
Context
::
create
();
vx_uint16
vComp
=
ivx
::
compiledWithVersion
();
vx_uint16
vCurr
=
context
.
version
();
g_haveOpenVX
=
VX_VERSION_MAJOR
(
vComp
)
==
VX_VERSION_MAJOR
(
vCurr
)
&&
VX_VERSION_MINOR
(
vComp
)
==
VX_VERSION_MINOR
(
vCurr
)
?
1
:
0
;
}
catch
(
const
ivx
::
WrapperError
&
)
{
g_haveOpenVX
=
0
;
}
catch
(
const
ivx
::
RuntimeError
&
)
{
g_haveOpenVX
=
0
;
}
}
return
g_haveOpenVX
==
1
;
#else
return
false
;
#endif
}
bool
useOpenVX
()
{
#ifdef HAVE_OPENVX
CoreTLSData
*
data
=
getCoreTlsData
().
get
();
if
(
data
->
useOpenVX
<
0
)
{
// enabled (if available) by default
data
->
useOpenVX
=
haveOpenVX
()
?
1
:
0
;
}
return
data
->
useOpenVX
>
0
;
#else
return
false
;
#endif
}
void
setUseOpenVX
(
bool
flag
)
{
#ifdef HAVE_OPENVX
if
(
haveOpenVX
()
)
{
CoreTLSData
*
data
=
getCoreTlsData
().
get
();
data
->
useOpenVX
=
flag
?
1
:
0
;
}
#else
CV_Assert
(
!
flag
&&
"OpenVX support isn't enabled at compile time"
);
#endif
}
}
// namespace cv
modules/core/src/precomp.hpp
View file @
1e2ddc30
...
...
@@ -262,11 +262,13 @@ struct CoreTLSData
device
(
0
),
useOpenCL
(
-
1
),
//#endif
useIPP
(
-
1
)
{
#ifdef HAVE_TEGRA_OPTIMIZATION
useTegra
=
-
1
;
,
useTegra
(
-
1
)
#endif
}
#ifdef HAVE_OPENVX
,
useOpenVX
(
-
1
)
#endif
{}
RNG
rng
;
//#ifdef HAVE_OPENCL
...
...
@@ -278,6 +280,9 @@ struct CoreTLSData
#ifdef HAVE_TEGRA_OPTIMIZATION
int
useTegra
;
// 1 - use, 0 - do not use, -1 - auto/not initialized
#endif
#ifdef HAVE_OPENVX
int
useOpenVX
;
// 1 - use, 0 - do not use, -1 - auto/not initialized
#endif
};
TLSData
<
CoreTLSData
>&
getCoreTlsData
();
...
...
modules/imgproc/src/canny.cpp
View file @
1e2ddc30
...
...
@@ -45,6 +45,8 @@
#include "opencv2/core/hal/intrin.hpp"
#include <queue>
#include "opencv2/core/openvx/ovx_defs.hpp"
#ifdef _MSC_VER
#pragma warning( disable: 4127 ) // conditional expression is constant
#endif
...
...
@@ -775,6 +777,64 @@ private:
ptrdiff_t
mapstep
;
};
#ifdef HAVE_OPENVX
static
bool
openvx_canny
(
const
Mat
&
src
,
Mat
&
dst
,
int
loVal
,
int
hiVal
,
int
kSize
,
bool
useL2
)
{
using
namespace
ivx
;
Context
context
=
Context
::
create
();
try
{
Image
_src
=
Image
::
createFromHandle
(
context
,
Image
::
matTypeToFormat
(
src
.
type
()),
Image
::
createAddressing
(
src
),
src
.
data
);
Image
_dst
=
Image
::
createFromHandle
(
context
,
Image
::
matTypeToFormat
(
dst
.
type
()),
Image
::
createAddressing
(
dst
),
dst
.
data
);
Threshold
threshold
=
Threshold
::
createRange
(
context
,
VX_TYPE_UINT8
,
saturate_cast
<
uchar
>
(
loVal
),
saturate_cast
<
uchar
>
(
hiVal
));
#if 0
// the code below is disabled because vxuCannyEdgeDetector()
// ignores context attribute VX_CONTEXT_IMMEDIATE_BORDER
// FIXME: may fail in multithread case
border_t prevBorder = context.immediateBorder();
context.setImmediateBorder(VX_BORDER_REPLICATE);
IVX_CHECK_STATUS( vxuCannyEdgeDetector(context, _src, threshold, kSize, (useL2 ? VX_NORM_L2 : VX_NORM_L1), _dst) );
context.setImmediateBorder(prevBorder);
#else
// alternative code without vxuCannyEdgeDetector()
Graph
graph
=
Graph
::
create
(
context
);
ivx
::
Node
node
=
ivx
::
Node
(
vxCannyEdgeDetectorNode
(
graph
,
_src
,
threshold
,
kSize
,
(
useL2
?
VX_NORM_L2
:
VX_NORM_L1
),
_dst
)
);
node
.
setBorder
(
VX_BORDER_REPLICATE
);
graph
.
verify
();
graph
.
process
();
#endif
#ifdef VX_VERSION_1_1
_src
.
swapHandle
();
_dst
.
swapHandle
();
#endif
}
catch
(
const
WrapperError
&
e
)
{
//CV_DbgAssert(!"openvx_canny - WrapperError");
return
false
;
}
catch
(
const
RuntimeError
&
e
)
{
//CV_DbgAssert(!"openvx_canny - RuntimeError");
return
false
;
}
return
true
;
}
#endif // HAVE_OPENVX
void
Canny
(
InputArray
_src
,
OutputArray
_dst
,
double
low_thresh
,
double
high_thresh
,
int
aperture_size
,
bool
L2gradient
)
...
...
@@ -805,6 +865,19 @@ void Canny( InputArray _src, OutputArray _dst,
Mat
src
=
_src
.
getMat
(),
dst
=
_dst
.
getMat
();
CV_OVX_RUN
(
src
.
type
()
==
CV_8UC1
&&
!
src
.
isSubmatrix
()
&&
src
.
cols
>=
aperture_size
&&
src
.
rows
>=
aperture_size
,
openvx_canny
(
src
,
dst
,
cvFloor
(
low_thresh
),
cvFloor
(
high_thresh
),
aperture_size
,
L2gradient
)
);
#ifdef HAVE_TEGRA_OPTIMIZATION
if
(
tegra
::
useTegra
()
&&
tegra
::
canny
(
src
,
dst
,
low_thresh
,
high_thresh
,
aperture_size
,
L2gradient
))
return
;
...
...
modules/imgproc/src/deriv.cpp
View file @
1e2ddc30
...
...
@@ -263,8 +263,8 @@ namespace cv
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
//since OpenVX standart says nothing about thread-safety for now
vx_border_t
prevBorder
=
ctx
.
borderMode
();
ctx
.
set
BorderMode
(
border
);
vx_border_t
prevBorder
=
ctx
.
immediateBorder
();
ctx
.
set
ImmediateBorder
(
border
);
if
(
dtype
==
CV_16SC1
&&
ksize
==
3
&&
((
dx
|
dy
)
==
1
)
&&
(
dx
+
dy
)
==
1
)
{
if
(
dx
)
...
...
@@ -277,7 +277,7 @@ namespace cv
#if VX_VERSION <= VX_VERSION_1_0
if
(
ctx
.
vendorID
()
==
VX_ID_KHRONOS
&&
((
vx_size
)(
src
.
cols
)
<=
ctx
.
convolutionMaxDimension
()
||
(
vx_size
)(
src
.
rows
)
<=
ctx
.
convolutionMaxDimension
()))
{
ctx
.
set
BorderMode
(
prevBorder
);
ctx
.
set
ImmediateBorder
(
prevBorder
);
return
false
;
}
#endif
...
...
@@ -292,7 +292,7 @@ namespace cv
cnv
.
setScale
(
cscale
);
ivx
::
IVX_CHECK_STATUS
(
vxuConvolve
(
ctx
,
ia
,
cnv
,
ib
));
}
ctx
.
set
BorderMode
(
prevBorder
);
ctx
.
set
ImmediateBorder
(
prevBorder
);
return
true
;
}
catch
(
ivx
::
RuntimeError
&
e
)
...
...
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