Ask Your Question

Revision history [back]

OpenCV 3.1 UMat assignment

I am trying to implement a performance upgrade to the project of my company. The project depends on OpenCV and recently I have successfully upgraded to OpenCV 3.1 to use UMat. Though I cant find a complete tutorial on it except basic operations. So I am stuck at the following:

   Mat m (width, height, type, someData, step);
    cv::UMat * ptr = new cv::UMat (width, height, type);
    //dont ask me why the hell we are using a pointer to the smart mat object (my project leader insists)

This doesnt work

  ptr->setTo (m);

Neither does this:

m.copyTo(*ptr);

These cause an exception.

ptr=&m.getUMat(cv::ACCESS_RW);

And this one results with a two dimensional mat with 0 rows and 0 cols... Also another case is:

some global cv::UMat gloMat; //initialized
function()
{
cv::UMat mat;
gloMat.copyTo(mat); //doesnt work!!! same result 2 dims 0 rows 0 cols

gloMat.getMat(cv::ACCESS_READ).copyTo (mat.getMat(cv::ACCESS_WRITE)); // this doesnt work as well !!!
return mat;
}

Need help. Thanks in advance!!!!