#ifndef IVX_USE_CXX98
#include <type_traits>
+ namespace ivx
+ {
+ using std::is_same;
+ using std::is_pointer;
+ }
#else
namespace ivx
{
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;
}
enum UserMemoryMode
{
- COPY, MAP_TO_VX
+ COPY, USER_MEM
};
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");
}
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();
"{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);
{
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;
enum UserMemoryMode
{
- COPY, MAP_TO_VX, MAP_FROM_VX
+ COPY, USER_MEM, MAP
};
ivx::Graph createProcessingGraph(ivx::Image& inputImage, ivx::Image& outputImage)
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);
{
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());
//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
"{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);
{
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
{
enum UserMemoryMode
{
- COPY, MAP_TO_VX, MAP_FROM_VX
+ COPY, USER_MEM, MAP
};
ivx::Graph createProcessingGraph(ivx::Image& inputImage, ivx::Image& outputImage)
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);
Graph graph = createProcessingGraph(ivxImage, ivxResult);
- std::vector<void*> ptrs;
-
bool stop = false;
while (!stop)
{
//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);
#ifdef VX_VERSION_1_1
//restore handle
- if (mode == MAP_TO_VX)
+ if (mode == USER_MEM)
{
- ivxResult.swapHandle(prevPtrs);
+ ivxResult.swapHandle(prevPtrs, ptrs);
}
#endif
//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
}
"{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);
{
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
{