提交 695b2017 编写于 作者: R Rostislav Vasilikhin 提交者: Alexander Alekhin

Merge pull request #7794 from savuor:fix/ovx_cvt_continuous

Fixed OpenVX wrapper for Mat::convertTo() (#7794)

* fixed for cases of unrolled (w*h x 1) matrices

* more error handling
上级 cb46946d
......@@ -4641,26 +4641,45 @@ cvtScaleHalf_<short, float>( const short* src, size_t sstep, float* dst, size_t
}
#ifdef HAVE_OPENVX
#ifdef _DEBUG
#define VX_DbgThrow(s) CV_Error(cv::Error::StsInternal, (s))
#else
#define VX_DbgThrow(s) return false;
#endif
template<typename T, typename DT>
static bool _openvx_cvt(const T* src, size_t sstep,
DT* dst, size_t dstep, Size size)
DT* dst, size_t dstep, Size continuousSize)
{
using namespace ivx;
if(!(size.width > 0 && size.height > 0))
if(!(continuousSize.width > 0 && continuousSize.height > 0 && sstep > 0 && dstep > 0))
{
return true;
}
CV_Assert(sstep / sizeof(T) == dstep / sizeof(DT));
//.height is for number of continuous pieces
//.width is for length of one piece
Size imgSize = continuousSize;
if(continuousSize.height == 1)
{
//continuous case
imgSize.width = sstep / sizeof(T);
imgSize.height = continuousSize.width / (sstep / sizeof(T));
}
try
{
Context context = Context::create();
Image srcImage = Image::createFromHandle(context, Image::matTypeToFormat(DataType<T>::type),
Image::createAddressing(size.width, size.height,
Image::createAddressing(imgSize.width, imgSize.height,
(vx_uint32)sizeof(T), (vx_uint32)sstep),
(void*)src);
Image dstImage = Image::createFromHandle(context, Image::matTypeToFormat(DataType<DT>::type),
Image::createAddressing(size.width, size.height,
Image::createAddressing(imgSize.width, imgSize.height,
(vx_uint32)sizeof(DT), (vx_uint32)dstep),
(void*)dst);
......@@ -4674,13 +4693,11 @@ static bool _openvx_cvt(const T* src, size_t sstep,
}
catch (RuntimeError & e)
{
CV_Error(CV_StsInternal, e.what());
return false;
VX_DbgThrow(e.what());
}
catch (WrapperError & e)
{
CV_Error(CV_StsInternal, e.what());
return false;
VX_DbgThrow(e.what());
}
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册