1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

added setIdentity to T-API

This commit is contained in:
Ilya Lavrenov
2013-11-30 17:40:03 +04:00
parent 3e586f42a0
commit 6ab297718d
2 changed files with 86 additions and 1 deletions
+27 -1
View File
@@ -41,6 +41,7 @@
//M*/
#include "precomp.hpp"
#include "opencl_kernels.hpp"
/****************************************************************************************\
* [scaled] Identity matrix initialization *
@@ -2368,10 +2369,35 @@ void cv::vconcat(InputArray _src, OutputArray dst)
}
//////////////////////////////////////// set identity ////////////////////////////////////////////
namespace cv {
static bool ocl_setIdentity( InputOutputArray _m, const Scalar& s )
{
int type = _m.type(), cn = CV_MAT_CN(type);
if (cn == 3)
return false;
UMat m = _m.getUMat();
ocl::Kernel k("setIdentity", ocl::core::set_identity_oclsrc,
format("-D T=%s", ocl::memopTypeToStr(type)));
k.args(ocl::KernelArg::WriteOnly(m), ocl::KernelArg::Constant(Mat(1, 1, type, s)));
size_t globalsize[2] = { m.cols, m.rows };
return k.run(2, globalsize, NULL, false);
}
}
void cv::setIdentity( InputOutputArray _m, const Scalar& s )
{
CV_Assert( _m.dims() <= 2 );
if (ocl::useOpenCL() && _m.isUMat() && ocl_setIdentity(_m, s))
return;
Mat m = _m.getMat();
CV_Assert( m.dims <= 2 );
int i, j, rows = m.rows, cols = m.cols, type = m.type();
if( type == CV_32FC1 )