2016-12-30 129 views
3

在CMake中,我用OpenCL打开了OpenCV启用(它自动检测到OPENCL_INCLUDE_DIR路径,但OPENCL_LIBRARY是空的,即使在单击配置后,对于OPENCL_LIBRARY我也没有看到浏览按钮。 OpenCV的二进制文件,然后我运行下面的代码用OpenCL支持构建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从这link并尝试建立但没有OpenCL二进制文件(而是我看到了opengl dll文件[glew32.dll & glut32.dll]。我如何通过链接OPENCL_LIBRARY与OpenCL构建OpenCV?

回答

1

我相信你有OpenCL,因此你的电话haveOpenCL和版本请求的结果。我不确定您的性能测试的结果等同于您没有OpenCL。

如果你想了解OpenCL,我会后退一步,先弄明白,然后试着理解OpenCV。

你的链接没有用,你试过this。它有一个指向当前AMD APP SDK(3.0)的链接。我将通过该设置并确保您可以使OpenCL示例在您的系统上构建/工作,然后您应该能够解决OpenCV无法正常工作的原因(如果它确实不是)。

至于性能,好吧,这取决于。每次您向显卡发送数据或从显卡发送数据时,都需要付出代价;透明API旨在为您提供这种选择:如果将它发送到卡以加快处理速度,那么值得在那里旅行......如果它不值得这次旅行,那么实际上性能会更差。此外,并非所有库都将在GPU上运行。请参阅opencv.org的一些解释。

+0

我在C:/ windows/System32中发现opencl.dll,删除它。但是使用了GPU。 也可以回答[this](http://stackoverflow.com/questions/41688751/understanding-the-usage-of-opencl-in-opencv-mat-umat-objects?noredirect=1#comment70603090_41688751)问题 –