加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 使用OpenCL支持构建OpenCV

发布时间:2020-12-16 07:20:16 所属栏目:百科 来源:网络整理
导读:在CMake中,我使用OpenCL Enable ON构建OpenCV(它自动检测到OPENCL_INCLUDE_DIR路径但是OPENCL_LIBRARY是空的,即使在点击配置之后.对于OPENCL_LIBRARY我也看不到浏览按钮..生成opencv二进制文件之后我运行下面的代码 #include iostream#include fstream#inclu
在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的性能没有任何区别.

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

解决方法

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

如果你想了解OpenCL,我会退后一步,先找出来,然后尝试用它来理解OpenCV.

您的链接不起作用,您是否尝试了this.它有一个指向当前AMD APP SDK(3.0)的链接我将通过该设置并确保您可以在您的系统上构建/运行OpenCL示例然后您应该能够解决为什么它不能在OpenCV中工作(如果它确实不是).

至于性能,这取决于.每次向显卡发送数据或从显卡发送数据时,都需要付费;透明API旨在为您做出选择:如果将其发送到卡上以便更快处理,那么值得一游又一次……如果不值得旅行,您实际上会有更差的性能.此外,并非所有库都可以在GPU上运行.请参阅opencv.org的一些解释.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读