|
|
@ -1838,6 +1838,160 @@ public: |
|
|
|
/// vxCreateVirtualArray() wrapper
|
|
|
|
/// vxCreateVirtualArray() wrapper
|
|
|
|
static Array createVirtual(vx_graph g, vx_enum type, vx_size capacity) |
|
|
|
static Array createVirtual(vx_graph g, vx_enum type, vx_size capacity) |
|
|
|
{ return Array(vxCreateVirtualArray(g, type, capacity)); } |
|
|
|
{ return Array(vxCreateVirtualArray(g, type, capacity)); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef VX_VERSION_1_1 |
|
|
|
|
|
|
|
static const vx_enum |
|
|
|
|
|
|
|
VX_MEMORY_TYPE_HOST = VX_IMPORT_TYPE_HOST, |
|
|
|
|
|
|
|
VX_ARRAY_ITEMTYPE = VX_ARRAY_ATTRIBUTE_ITEMTYPE, |
|
|
|
|
|
|
|
VX_ARRAY_NUMITEMS = VX_ARRAY_ATTRIBUTE_NUMITEMS, |
|
|
|
|
|
|
|
VX_ARRAY_CAPACITY = VX_ARRAY_ATTRIBUTE_CAPACITY, |
|
|
|
|
|
|
|
VX_ARRAY_ITEMSIZE = VX_ARRAY_ATTRIBUTE_ITEMSIZE; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> |
|
|
|
|
|
|
|
void query(vx_enum att, T& value) const |
|
|
|
|
|
|
|
{ IVX_CHECK_STATUS( vxQueryArray(ref, att, &value, sizeof(value)) ); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vx_enum itemType() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vx_enum v; |
|
|
|
|
|
|
|
query(VX_ARRAY_ITEMTYPE, v); |
|
|
|
|
|
|
|
return v; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vx_size itemSize() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vx_size v; |
|
|
|
|
|
|
|
query(VX_ARRAY_ITEMSIZE, v); |
|
|
|
|
|
|
|
return v; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vx_size capacity() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vx_size v; |
|
|
|
|
|
|
|
query(VX_ARRAY_CAPACITY, v); |
|
|
|
|
|
|
|
return v; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vx_size itemCount() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vx_size v; |
|
|
|
|
|
|
|
query(VX_ARRAY_NUMITEMS, v); |
|
|
|
|
|
|
|
return v; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyRangeTo(size_t start, size_t end, void* data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!data) throw WrapperError(std::string(__func__) + "(): output pointer is 0"); |
|
|
|
|
|
|
|
#ifdef VX_VERSION_1_1 |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxCopyArrayRange(ref, start, end, itemSize(), data, VX_READ_ONLY, VX_MEMORY_TYPE_HOST)); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
vx_size stride = itemSize(); |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxAccessArrayRange(ref, start, end, &stride, &data, VX_READ_ONLY)); |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxCommitArrayRange(ref, start, end, data)); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyTo(void* data) |
|
|
|
|
|
|
|
{ copyRangeTo(0, itemCount(), data); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyRangeFrom(size_t start, size_t end, const void* data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!data) throw WrapperError(std::string(__func__) + "(): input pointer is 0"); |
|
|
|
|
|
|
|
#ifdef VX_VERSION_1_1 |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxCopyArrayRange(ref, start, end, itemSize(), const_cast<void*>(data), VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST)); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
vx_size stride = itemSize(); |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxAccessArrayRange(ref, start, end, &stride, const_cast<void**>(&data), VX_WRITE_ONLY)); |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxCommitArrayRange(ref, start, end, data)); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyFrom(const void* data) |
|
|
|
|
|
|
|
{ copyRangeFrom(0, itemCount(), data); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyRange(size_t start, size_t end, void* data, vx_enum usage, vx_enum memType = VX_MEMORY_TYPE_HOST) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!data) throw WrapperError(std::string(__func__) + "(): data pointer is 0"); |
|
|
|
|
|
|
|
#ifdef VX_VERSION_1_1 |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxCopyArrayRange(ref, start, end, itemSize(), data, usage, memType)); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
vx_size stride = itemSize(); |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxAccessArrayRange(ref, start, end, &stride, &data, usage)); |
|
|
|
|
|
|
|
IVX_CHECK_STATUS(vxCommitArrayRange(ref, start, end, data)); |
|
|
|
|
|
|
|
(void)memType; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copy(void* data, vx_enum usage, vx_enum memType = VX_MEMORY_TYPE_HOST) |
|
|
|
|
|
|
|
{ copyRange(0, itemCount(), data, usage, memType); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> void copyRangeTo(size_t start, size_t end, std::vector<T>& data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (TypeToEnum<T>::value != itemType()) throw WrapperError(std::string(__func__) + "(): destination type is wrong"); |
|
|
|
|
|
|
|
if (data.size() != (end - start)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (data.size() == 0) |
|
|
|
|
|
|
|
data.resize((end - start)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
throw WrapperError(std::string(__func__) + "(): destination size is wrong"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
copyRangeTo(start, end, &data[0]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> void copyTo(std::vector<T>& data) |
|
|
|
|
|
|
|
{ copyRangeTo(0, itemCount(), data); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> void copyRangeFrom(size_t start, size_t end, const std::vector<T>& data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (TypeToEnum<T>::value != itemType()) throw WrapperError(std::string(__func__) + "(): source type is wrong"); |
|
|
|
|
|
|
|
if (data.size() != (end - start)) throw WrapperError(std::string(__func__) + "(): source size is wrong"); |
|
|
|
|
|
|
|
copyRangeFrom(start, end, &data[0]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> void copyFrom(std::vector<T>& data) |
|
|
|
|
|
|
|
{ copyRangeFrom(0, itemCount(), data); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef IVX_USE_OPENCV |
|
|
|
|
|
|
|
void copyRangeTo(size_t start, size_t end, cv::Mat& m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (m.type() != enumToCVType(itemType())) throw WrapperError(std::string(__func__) + "(): destination type is wrong"); |
|
|
|
|
|
|
|
if (!( |
|
|
|
|
|
|
|
((vx_size)(m.rows) == (end - start) && m.cols == 1) || |
|
|
|
|
|
|
|
((vx_size)(m.cols) == (end - start) && m.rows == 1) |
|
|
|
|
|
|
|
) && !m.empty()) throw WrapperError(std::string(__func__) + "(): destination size is wrong"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m.isContinuous() && (vx_size)(m.total()) == (end - start)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
copyRangeTo(start, end, m.ptr()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
cv::Mat tmp(1, (int)(end - start), enumToCVType(itemType())); |
|
|
|
|
|
|
|
copyRangeTo(start, end, tmp.ptr()); |
|
|
|
|
|
|
|
if (m.empty()) |
|
|
|
|
|
|
|
m = tmp; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
tmp.copyTo(m); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyTo(cv::Mat& m) |
|
|
|
|
|
|
|
{ copyRangeTo(0, itemCount(), m); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyRangeFrom(size_t start, size_t end, const cv::Mat& m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!( |
|
|
|
|
|
|
|
((vx_size)(m.rows) == (end - start) && m.cols == 1) || |
|
|
|
|
|
|
|
((vx_size)(m.cols) == (end - start) && m.rows == 1) |
|
|
|
|
|
|
|
)) throw WrapperError(std::string(__func__) + "(): source size is wrong"); |
|
|
|
|
|
|
|
if (m.type() != enumToCVType(itemType())) throw WrapperError(std::string(__func__) + "(): source type is wrong"); |
|
|
|
|
|
|
|
copyFrom(m.isContinuous() ? m.ptr() : m.clone().ptr()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copyFrom(const cv::Mat& m) |
|
|
|
|
|
|
|
{ copyRangeFrom(0, itemCount(), m); } |
|
|
|
|
|
|
|
#endif //IVX_USE_OPENCV
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|