执行此代码时:
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
int main (int argc, char* argv[]){
try
{
cv::Mat src_host = cv::imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
cv::gpu::GpuMat dst, src;
src.upload(src_host);
cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);
cv::Mat result_host;
dst.download(result_host);
cv::imshow("Result", result_host);
cv::waitKey();
}
catch(const cv::Exception& ex)
{
std::cout << "Error: " << ex.what() << std::endl;
}
return 0;
}
编译得很好......但我运行并收到以下错误:
OpenCV Error: Unknown error code -216 (The library is compiled without CUDA support) in copy, file /home/cbib/Descargas/OpenCV-2.4.3/modules/core/src/gpumat.cpp, line 736
我已经安装了opencv cuda,并且如图所示。
我的操作系统是 Ubuntu Server 10.04。