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
9032a7ab
Commit
9032a7ab
authored
Nov 17, 2016
by
Rostislav Vasilikhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor fixes in samples and ivx.hpp
parent
5c969d19
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
37 deletions
+37
-37
ivx.hpp
3rdparty/openvx/include/ivx.hpp
+7
-2
no_wrappers.cpp
samples/openvx/no_wrappers.cpp
+6
-10
wrappers.cpp
samples/openvx/wrappers.cpp
+10
-10
wrappers_video.cpp
samples/openvx/wrappers_video.cpp
+14
-15
No files found.
3rdparty/openvx/include/ivx.hpp
View file @
9032a7ab
...
...
@@ -58,6 +58,11 @@ Details: TBD
#ifndef IVX_USE_CXX98
#include <type_traits>
namespace
ivx
{
using
std
::
is_same
;
using
std
::
is_pointer
;
}
#else
namespace
ivx
{
...
...
@@ -1517,8 +1522,8 @@ static const vx_enum
static
Threshold
createRange
(
vx_context
c
,
vx_enum
dataType
,
vx_int32
valLower
,
vx_int32
valUpper
)
{
Threshold
thr
=
create
(
c
,
VX_THRESHOLD_TYPE_RANGE
,
dataType
);
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
thr
.
ref
,
VX_THRESHOLD_THRESHOLD_LOWER
,
&
val
1
,
sizeof
(
val1
))
);
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
thr
.
ref
,
VX_THRESHOLD_THRESHOLD_UPPER
,
&
val
2
,
sizeof
(
val2
))
);
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
thr
.
ref
,
VX_THRESHOLD_THRESHOLD_LOWER
,
&
val
Lower
,
sizeof
(
valLower
))
);
IVX_CHECK_STATUS
(
vxSetThresholdAttribute
(
thr
.
ref
,
VX_THRESHOLD_THRESHOLD_UPPER
,
&
val
Upper
,
sizeof
(
valUpper
))
);
return
thr
;
}
...
...
samples/openvx/no_wrappers.cpp
View file @
9032a7ab
...
...
@@ -24,7 +24,7 @@ typedef uintptr_t vx_map_id;
enum
UserMemoryMode
{
COPY
,
MAP_TO_VX
COPY
,
USER_MEM
};
vx_image
convertCvMatToVxImage
(
vx_context
context
,
cv
::
Mat
image
,
bool
toCopy
)
...
...
@@ -89,11 +89,7 @@ vx_image convertCvMatToVxImage(vx_context context, cv::Mat image, bool toCopy)
}
else
{
#ifdef VX_VERSION_1_1
ovxImage
=
vxCreateImageFromHandle
(
context
,
color
,
&
addr
,
(
void
*
const
*
)
&
ovxData
,
VX_MEMORY_TYPE_HOST
);
#else
ovxImage
=
vxCreateImageFromHandle
(
context
,
color
,
&
addr
,
(
void
**
)
&
ovxData
,
VX_MEMORY_TYPE_HOST
);
#endif
if
(
vxGetStatus
((
vx_reference
)
ovxImage
)
!=
VX_SUCCESS
)
throw
std
::
runtime_error
(
"Failed to create image from handle"
);
}
...
...
@@ -322,7 +318,7 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
cv
::
waitKey
(
0
);
//we need to take user memory back before releasing the image
if
(
mode
==
MAP_TO_VX
)
if
(
mode
==
USER_MEM
)
swapVxImage
(
ovxImage
);
cv
::
destroyAllWindows
();
...
...
@@ -339,7 +335,7 @@ int main(int argc, char *argv[])
"{image | <none> | image to be processed}"
"{mode | copy | user memory interaction mode:
\n
"
"copy: create VX images and copy data to/from them
\n
"
"
map_to_vx
: use handles to user-allocated memory}"
"
user_mem
: use handles to user-allocated memory}"
;
cv
::
CommandLineParser
parser
(
argc
,
argv
,
keys
);
...
...
@@ -357,11 +353,11 @@ int main(int argc, char *argv[])
{
mode
=
COPY
;
}
else
if
(
modeString
==
"
map_to_vx
"
)
else
if
(
modeString
==
"
user_mem
"
)
{
mode
=
MAP_TO_VX
;
mode
=
USER_MEM
;
}
else
if
(
modeString
==
"map
_from_vx
"
)
else
if
(
modeString
==
"map"
)
{
std
::
cerr
<<
modeString
<<
" is not implemented in this sample"
<<
std
::
endl
;
return
-
1
;
...
...
samples/openvx/wrappers.cpp
View file @
9032a7ab
...
...
@@ -12,7 +12,7 @@
enum
UserMemoryMode
{
COPY
,
MAP_TO_VX
,
MAP_FROM_VX
COPY
,
USER_MEM
,
MAP
};
ivx
::
Graph
createProcessingGraph
(
ivx
::
Image
&
inputImage
,
ivx
::
Image
&
outputImage
)
...
...
@@ -91,7 +91,7 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
Image
ivxResult
;
Image
::
Patch
resultPatch
;
Mat
output
;
if
(
mode
==
COPY
||
mode
==
MAP
_FROM_VX
)
if
(
mode
==
COPY
||
mode
==
MAP
)
{
//we will copy or map data from vx_image to cv::Mat
ivxResult
=
ivx
::
Image
::
create
(
context
,
width
,
height
,
VX_DF_IMAGE_U8
);
...
...
@@ -116,7 +116,7 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
{
ivxResult
.
copyTo
(
0
,
output
);
}
else
if
(
mode
==
MAP
_FROM_VX
)
else
if
(
mode
==
MAP
)
{
//create cv::Mat based on vx_image mapped data
resultPatch
.
map
(
ivxResult
,
0
,
ivxResult
.
getValidRegion
());
...
...
@@ -144,7 +144,7 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
//we should take user memory back before release
//(it's not done automatically according to standard)
ivxImage
.
swapHandle
();
if
(
mode
==
MAP_TO_VX
)
ivxResult
.
swapHandle
();
if
(
mode
==
USER_MEM
)
ivxResult
.
swapHandle
();
}
#endif
...
...
@@ -173,8 +173,8 @@ int main(int argc, char *argv[])
"{image | <none> | image to be processed}"
"{mode | copy | user memory interaction mode:
\n
"
"copy: create VX images and copy data to/from them
\n
"
"
map_to_vx
: use handles to user-allocated memory
\n
"
"map
_from_vx
: map resulting VX image to user memory}"
"
user_mem
: use handles to user-allocated memory
\n
"
"map: map resulting VX image to user memory}"
;
cv
::
CommandLineParser
parser
(
argc
,
argv
,
keys
);
...
...
@@ -192,13 +192,13 @@ int main(int argc, char *argv[])
{
mode
=
COPY
;
}
else
if
(
modeString
==
"
map_to_vx
"
)
else
if
(
modeString
==
"
user_mem
"
)
{
mode
=
MAP_TO_VX
;
mode
=
USER_MEM
;
}
else
if
(
modeString
==
"map
_from_vx
"
)
else
if
(
modeString
==
"map"
)
{
mode
=
MAP
_FROM_VX
;
mode
=
MAP
;
}
else
{
...
...
samples/openvx/wrappers_video.cpp
View file @
9032a7ab
...
...
@@ -12,7 +12,7 @@
enum
UserMemoryMode
{
COPY
,
MAP_TO_VX
,
MAP_FROM_VX
COPY
,
USER_MEM
,
MAP
};
ivx
::
Graph
createProcessingGraph
(
ivx
::
Image
&
inputImage
,
ivx
::
Image
&
outputImage
)
...
...
@@ -100,7 +100,7 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
Image
ivxResult
;
Mat
output
;
if
(
mode
==
COPY
||
mode
==
MAP
_FROM_VX
)
if
(
mode
==
COPY
||
mode
==
MAP
)
{
//we will copy or map data from vx_image to cv::Mat
ivxResult
=
ivx
::
Image
::
create
(
context
,
width
,
height
,
VX_DF_IMAGE_U8
);
...
...
@@ -117,8 +117,6 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
Graph
graph
=
createProcessingGraph
(
ivxImage
,
ivxResult
);
std
::
vector
<
void
*>
ptrs
;
bool
stop
=
false
;
while
(
!
stop
)
{
...
...
@@ -129,12 +127,13 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
//getting resulting image in cv::Mat
Image
::
Patch
resultPatch
;
std
::
vector
<
void
*>
prevPtrs
;
std
::
vector
<
void
*>
ptrs
;
std
::
vector
<
void
*>
prevPtrs
(
ivxResult
.
planes
());
if
(
mode
==
COPY
)
{
ivxResult
.
copyTo
(
0
,
output
);
}
else
if
(
mode
==
MAP
_FROM_VX
)
else
if
(
mode
==
MAP
)
{
//create cv::Mat based on vx_image mapped data
resultPatch
.
map
(
ivxResult
,
0
,
ivxResult
.
getValidRegion
(),
VX_READ_AND_WRITE
);
...
...
@@ -156,9 +155,9 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
#ifdef VX_VERSION_1_1
//restore handle
if
(
mode
==
MAP_TO_VX
)
if
(
mode
==
USER_MEM
)
{
ivxResult
.
swapHandle
(
prevPtrs
);
ivxResult
.
swapHandle
(
prevPtrs
,
ptrs
);
}
#endif
...
...
@@ -184,7 +183,7 @@ int ovxDemo(std::string inputPath, UserMemoryMode mode)
//we should take user memory back before release
//(it's not done automatically according to standard)
ivxImage
.
swapHandle
();
if
(
mode
==
MAP_TO_VX
)
ivxResult
.
swapHandle
();
if
(
mode
==
USER_MEM
)
ivxResult
.
swapHandle
();
}
#endif
}
...
...
@@ -210,8 +209,8 @@ int main(int argc, char *argv[])
"{video | <none> | video file to be processed}"
"{mode | copy | user memory interaction mode:
\n
"
"copy: create VX images and copy data to/from them
\n
"
"
map_to_vx
: use handles to user-allocated memory
\n
"
"map
_from_vx
: map resulting VX image to user memory}"
"
user_mem
: use handles to user-allocated memory
\n
"
"map: map resulting VX image to user memory}"
;
cv
::
CommandLineParser
parser
(
argc
,
argv
,
keys
);
...
...
@@ -229,13 +228,13 @@ int main(int argc, char *argv[])
{
mode
=
COPY
;
}
else
if
(
modeString
==
"
map_to_vx
"
)
else
if
(
modeString
==
"
user_mem
"
)
{
mode
=
MAP_TO_VX
;
mode
=
USER_MEM
;
}
else
if
(
modeString
==
"map
_from_vx
"
)
else
if
(
modeString
==
"map"
)
{
mode
=
MAP
_FROM_VX
;
mode
=
MAP
;
}
else
{
...
...
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