mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
minor fixes in samples and ivx.hpp
This commit is contained in:
parent
5c969d1972
commit
9032a7ab81
9
3rdparty/openvx/include/ivx.hpp
vendored
9
3rdparty/openvx/include/ivx.hpp
vendored
@ -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, &val1, sizeof(val1)) );
|
||||
IVX_CHECK_STATUS( vxSetThresholdAttribute(thr.ref, VX_THRESHOLD_THRESHOLD_UPPER, &val2, sizeof(val2)) );
|
||||
IVX_CHECK_STATUS( vxSetThresholdAttribute(thr.ref, VX_THRESHOLD_THRESHOLD_LOWER, &valLower, sizeof(valLower)) );
|
||||
IVX_CHECK_STATUS( vxSetThresholdAttribute(thr.ref, VX_THRESHOLD_THRESHOLD_UPPER, &valUpper, sizeof(valUpper)) );
|
||||
return thr;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user