Ask Your Question

Revision history [back]

I am also running into this issue a lot. Apparently I can tell, that the error occurs mostly when the original created Mat/UMat object is released before the other ones (got by calling getMat/getUMat). I.e.:

cv::UMat umat;  
cv::Mat mat(200, 400, CV_8U);
umat = mat.getUMat(cv::ACCESS_RW, cv::UMatUsageFlags::USAGE_DEFAULT);
// Not calling umat.release() would leave both until end of scope where the original 
// object (mat) could be destroyed first.
umat.release();

From my understanding this should be handled by urefcount and refcount? Seems to be a bug in handling the ownership of the UMatData. Nevertheless you should be safe if keeping the 'base' (the mat object that created the data) alive and make sure it is deleted last.