关于OpenCV报错:“Error: Gpu API call (out of memory) in ”的解决

在跑OpenCV程序时报错:“Error: Gpu API call (out of memory) in <unnamed>::DefaultAllocator::allocate......",定位出错的程序段为:

for(int i=0;i<img_names.size();i++)
{
    cuda::GpuMat img,gray;
    cuda::GpuMat key_point;
    vector<KeyPoint> key_points;
    cuda::GpuMat descriptor;
    ...
}
    

将这个循环中定义的变量放到循环外解决问题,避免了程序运行过程内存一直增加。

猜你喜欢

转载自blog.csdn.net/Z5122/article/details/85260298