使用OpenCL支持构建OpenCV



在CMake中,我在OpenCL Enable ON的情况下构建了OpenCV(它自动检测到OPENCL_INCLUDE_DIR路径,但OPENCL_LIBRARY是空的,即使在单击配置之后也是如此。对于OPENCL_LIBRARY,我也看不到浏览按钮。生成OpenCV二进制文件后,我运行以下代码

#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>
int main()
{
if (!cv::ocl::haveOpenCL())       
cout << "OpenCL is not avaiable..." << endl;          
else cout << "OpenCL is AVAILABLE! :) " << endl; //this is the output
cv::ocl::setUseOpenCL(true);
cout << context.ndevices() << " GPU devices are detected." << endl; 
for (int i = 0; i < context.ndevices(); i++)
{
cv::ocl::Device device = context.device(i);
cout << "name:              " << device.name() << endl;
cout << "available:         " << device.available() << endl;
cout << "imageSupport:      " << device.imageSupport() << endl;
cout << "OpenCL_C_Version:  " << device.OpenCL_C_Version() << endl;
cout << endl;
} //this works & i can see my video card name & opencl version
cv::ocl::Device(context.device(0));
}

当我使用UMat来测量性能时,使用(UMat)或不使用(Mat)OpenCL的性能没有任何差异。

我从这个链接下载了AMD-APP-SDK,并试图构建,但没有OpenCL二进制文件(相反,我看到了opengl dll文件[glew32.dll&glut32.dll]。我如何通过链接OpenCL_LIBRARY来构建OpenCV?

我相信您有OpenCL,因此是对haveOpenCL的调用和版本请求的结果。我不确定你的性能测试结果是否等于你没有OpenCL。

如果你想了解OpenCL,我会退一步,先弄清楚它,然后试着用它来理解OpenCV

你的链接不起作用,你试过这个吗。它有一个到当前AMD APP SDK(3.0)的链接,我会仔细检查该设置,并确保你可以在你的系统上构建/工作OpenCL示例,然后你应该能够解决它在OpenCV中不工作的原因(如果它真的不工作的话)。

至于表现,这取决于情况。每次你向显卡发送数据和从显卡发送数据都是有代价的;透明API的设计目的是为您做出这样的选择:如果将其发送到卡以进行更快的处理值得来回旅行。。。如果这次旅行不值得,你的表现实际上会更差。此外,并非所有库都将在GPU上运行。请参阅opencv.org.上的一些解释

最新更新