1. 问题点
opencv-4图像拼接官方示例代码,opencv-4.5.5/samples/cpp/stitching_detailed.cpp
打开--try_cuda yes
开关后运行测试,
opencv-4.5.5/modules/core/include/opencv2/core/private.cuda.hpp:112: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function ‘throw_no_cuda’
2. 分析
在代码seam_finder
处报错崩溃,提示throw_no_cuda
,事实上本地已编译带cuda
支持的opencv了。其他代码处使用cuda
的函数均无问题。唯独seam_finder
报错。
if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0)
seam_finder = makePtr<detail::GraphCutSeamFinderGpu>(GraphCutSeamFinderBase::COST_COLOR);
seam_finder->find(images_warped_f, corners, masks_warped);
使用cpu版本seam_finder
的执行正常。
https://github.com/opencv/opencv/issues/7344文中有提到,
seam_finder
的cuda版本底层依赖cv::cuda::graphcut
,在CUDA 8.0及以后的版本被抛弃,最后一个支持版本为CUDA 7.5。
3. Workaround
该问题2016即已爆出,至今仍未修复。
临时的解决办法,强制seam_finder
使用cpu模式(CPU模式会使用OpenCL加速),其他保持不变。