You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UMat refcount Error when setting UseOpenCL to false #8693
I'm currently changing all Mats in my program to UMats and have a crash with some functions (cv::convertTo and cv::reduce) which I don't think should happen.
Code runs fine with Mats
Code runs fine with UMats if UseOpenCL set to true
Code crashes with UMats if UseOpenCL set to false
Steps to reproduce
ocl::setUseOpenCL(false);
auto src = UMat::zeros({ 10,10 }, CV_32FC1);
reduce(src, src, 0, CV_REDUCE_SUM); //crashes with refcount Error
src.convertTo(src, CV_64FC1); //crashes with refcount Error
The error is: OpenCV Error: Assertion failed (u->refcount == 0) in cv::StdMatAllocator::deallocate, file opencv\sources\modules\core\src\matrix.cpp, line 214
Now you might say that I should simply use a different output UMat, but I would also like to write functions like this:
void foo(cv::InputArray src, cv::OutputArray dst)
{
cv::reduce(src, dst, 0, CV_REDUCE_SUM);
//do other stuff
}
int main()
{
ocl::setUseOpenCL(false);
auto src = UMat::zeros({ 10,10 }, CV_32FC1);
foo(src, src);
}
Currently I'm using the following fix to make the program run for all three cases:
Activity
[-]UMat refcount Error when setting UseOpenCL to flase[/-][+]UMat refcount Error when setting UseOpenCL to false[/+]dkurt commentedon Sep 5, 2017
Minimal example to reproduce it (summarized from
cv::reducecode):Fix opencv#8693
Fix opencv#8693
alalek commentedon Sep 6, 2017
Related: #8352
Fix opencv#8693