使用OpenCL支持构建OpenCV [英] Build OpenCV with OpenCL support

查看:347
本文介绍了使用OpenCL支持构建OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CMake中,我使用OpenCL启用ON构建了OpenCV(它自动检测到OPENCL_INCLUDE_DIR路径,但OPENCL_LIBRARY为空,即使单击了OPENCL_LIBRARY的配置.我也看不到浏览按钮..生成opencv二进制文件,然后运行以下代码

in CMake, I built OpenCV with OpenCL Enable ON(It automatically detected the OPENCL_INCLUDE_DIR path but the OPENCL_LIBRARY was empty, even after clicking config. for OPENCL_LIBRARY i don't see browse button either .. after generating opencv binaries then i run the below code

#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的性能都没有任何区别.

When i make use of UMat to measure the performance, the performance with(UMat) or without(Mat) OpenCL did not make any difference.

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

I downloaded AMD-APP-SDK from this link and tried to build but there was no OpenCL binaries (instead i saw opengl dll files[glew32.dll & glut32.dll]. How do i build OpenCV with OpenCL by linking the OPENCL_LIBRARY?

推荐答案

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

I believe you have OpenCL, hence the result of your call to haveOpenCL and from the version request. I'm not sure the results of your performance test equate that you don't have OpenCL.

如果您想了解OpenCL,我会退后一步,先弄清楚它,然后再尝试用它来了解OpenCV.

If you want to understand OpenCL, I would take a step back and figure it out first and then try to understand OpenCV with it.

您的链接无效,您是否尝试了.它具有到当前AMD APP SDK(3.0)的链接,我将通过该设置并确保您可以在系统上构建/运行OpenCL样本,然后您应该能够对为何它无法在OpenCV中工作进行故障排除(如果确实不是).

Your link didn't work, did you try this. It has a link to the current AMD APP SDK (3.0) I would go through that setup and make sure you can make the OpenCL samples build/work on your system and then you should be able to troubleshoot why it isn't working in OpenCV (if it truly isn't).

关于性能,这要视情况而定.每次与图形卡之间来回发送数据时,都会付出一定的代价;透明API旨在为您做出选择:如果将其发送到卡中以进行更快的处理值得在那儿旅行,然后再回去...如果不值得那次旅行,您实际上会获得较差的性能.此外,并非所有库都将在GPU上运行.请参见 opencv.org 上的一些解释.

As to performance, well, it depends. Every time you send data to and from the the graphics card it comes at a cost; the Transparent API was designed to make that choice for you: if sending it to the card for faster processing is worth the trip there and back... if it is not worth the trip you will actually have poorer performance. Additionally, not all of the library will run on the GPU. See some of the explanation on opencv.org.

这篇关于使用OpenCL支持构建OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆