Merge pull request #1034 from pengx17:2.4_oclmat_inoutarray

This commit is contained in:
Roman Donchenko 2013-06-24 12:27:25 +04:00 committed by OpenCV Buildbot
commit 171a56fe82
4 changed files with 69 additions and 1 deletions

View File

@ -1322,7 +1322,8 @@ public:
EXPR = 6 << KIND_SHIFT,
OPENGL_BUFFER = 7 << KIND_SHIFT,
OPENGL_TEXTURE = 8 << KIND_SHIFT,
GPU_MAT = 9 << KIND_SHIFT
GPU_MAT = 9 << KIND_SHIFT,
OCL_MAT =10 << KIND_SHIFT
};
_InputArray();

View File

@ -980,6 +980,11 @@ Mat _InputArray::getMat(int i) const
return !v.empty() ? Mat(size(i), t, (void*)&v[0]) : Mat();
}
if( k == OCL_MAT )
{
CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
}
CV_Assert( k == STD_VECTOR_MAT );
//if( k == STD_VECTOR_MAT )
{
@ -1062,6 +1067,11 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
return;
}
if( k == OCL_MAT )
{
CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
}
CV_Assert( k == STD_VECTOR_MAT );
//if( k == STD_VECTOR_MAT )
{
@ -1189,6 +1199,11 @@ Size _InputArray::size(int i) const
return tex->size();
}
if( k == OCL_MAT )
{
CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
}
CV_Assert( k == GPU_MAT );
//if( k == GPU_MAT )
{
@ -1303,6 +1318,11 @@ bool _InputArray::empty() const
if( k == OPENGL_TEXTURE )
return ((const ogl::Texture2D*)obj)->empty();
if( k == OCL_MAT )
{
CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
}
CV_Assert( k == GPU_MAT );
//if( k == GPU_MAT )
return ((const gpu::GpuMat*)obj)->empty();
@ -1523,6 +1543,11 @@ void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool all
return;
}
if( k == OCL_MAT )
{
CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
}
if( k == NONE )
{
CV_Error(CV_StsNullPtr, "create() called for the missing output array" );
@ -1634,6 +1659,11 @@ void _OutputArray::release() const
return;
}
if( k == OCL_MAT )
{
CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
}
CV_Assert( k == STD_VECTOR_MAT );
//if( k == STD_VECTOR_MAT )
{

View File

@ -248,6 +248,11 @@ namespace cv
operator Mat() const;
void download(cv::Mat &m) const;
//! convert to _InputArray
operator _InputArray();
//! convert to _OutputArray
operator _OutputArray();
//! returns a new oclMatrix header for the specified row
oclMat row(int y) const;
@ -387,6 +392,9 @@ namespace cv
int wholecols;
};
// convert InputArray/OutputArray to oclMat references
CV_EXPORTS oclMat& getOclMatRef(InputArray src);
CV_EXPORTS oclMat& getOclMatRef(OutputArray src);
///////////////////// mat split and merge /////////////////////////////////
//! Compose a multi-channel array from several single-channel arrays

View File

@ -74,6 +74,7 @@ namespace cv
}
}
////////////////////////////////////////////////////////////////////////
// convert_C3C4
static void convert_C3C4(const cl_mem &src, oclMat &dst)
@ -227,6 +228,34 @@ void cv::ocl::oclMat::upload(const Mat &m)
//download_channels = m.channels();
}
cv::ocl::oclMat::operator cv::_InputArray()
{
_InputArray newInputArray;
newInputArray.flags = cv::_InputArray::OCL_MAT;
newInputArray.obj = reinterpret_cast<void *>(this);
return newInputArray;
}
cv::ocl::oclMat::operator cv::_OutputArray()
{
_OutputArray newOutputArray;
newOutputArray.flags = cv::_InputArray::OCL_MAT;
newOutputArray.obj = reinterpret_cast<void *>(this);
return newOutputArray;
}
cv::ocl::oclMat& cv::ocl::getOclMatRef(InputArray src)
{
CV_Assert(src.flags & cv::_InputArray::OCL_MAT);
return *reinterpret_cast<oclMat*>(src.obj);
}
cv::ocl::oclMat& cv::ocl::getOclMatRef(OutputArray src)
{
CV_Assert(src.flags & cv::_InputArray::OCL_MAT);
return *reinterpret_cast<oclMat*>(src.obj);
}
void cv::ocl::oclMat::download(cv::Mat &m) const
{
CV_DbgAssert(!this->empty());