在启用和启用OpenCL的情况下构建OpenCV [英] Build OpenCV with OpenCL Enabled and ON

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

问题描述

我正在尝试在OpenCV上启用OpenCL的情况下运行简单代码.

I'm trying to run simple code with OpenCL enabled on OpenCV.

我已经阅读了OCL文档的介绍,并按照指示,使用以下标志构建了opencv:WITH_OPENCL = ON.

I've read the intro to OCL documentation and, as instructed, I built opencv with this flag: WITH_OPENCL=ON.

我通过执行cmake -DWITH_OPENCL = ON来做到这一点,然后在Mac(OS X Yosemite)上构建了opencv.

I did this by doing cmake -DWITH_OPENCL=ON and then built opencv on Mac (OS X Yosemite).

然后我尝试运行我的代码,但是根据我的代码,haveOpenCL()为false.

I then tried to run my code, but, according to my code, haveOpenCL() is false.

#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>

using namespace std;

int  main ()
{
        cv::ocl::setUseOpenCL(true);
        cout << cv::ocl::haveOpenCL() << endl;
        if  ( ! cv::ocl::haveOpenCL ())
        {
                cout  <<  "OpenCL IS not avaiable ..."  <<  endl ;
                return 0;
        }

有人知道如何启动并运行OpenCV-OpenCL吗?

Does anybody know how to get OpenCV-OpenCL up and running?

更新:

我在opencv/build中检查了我的cvconfig.h文件,这就是有关OpenCL的内容: /* OpenCL支持/ / #undef HAVE_OPENCL / / #undef HAVE_OPENCL_STATIC / / #undef HAVE_OPENCL_SVM */

I checked my cvconfig.h file in opencv/build and this is what it says about OpenCL: /* OpenCL Support / / #undef HAVE_OPENCL / / #undef HAVE_OPENCL_STATIC / / #undef HAVE_OPENCL_SVM */

我假设如果确实启用了OpenCL,则第二行应类似于 #define HAVE_OPENCL 1

I'm assuming that if OpenCL is really enabled, then the second line should be something like #define HAVE_OPENCL 1

这是自动生成的,因此如何解决此问题,以使HAVE_OPENCL为1?

This is auto-generated, so how can I fix this so that HAVE_OPENCL is 1?

推荐答案

这就是我安装OpenCV 3.0的方式,也是我检查其工作方式的方式.在此处检查文档: http://docs.opencv.org/modules /ocl/doc/introduction.html

That is how I installed OpenCV 3.0 and that is also how I checked that it was working. Checking the documentation here : http://docs.opencv.org/modules/ocl/doc/introduction.html

要正确运行OCL模块,您需要具有设备供应商(通常是设备驱动程序)提供的OpenCL运行时.

要启用OCL支持,请使用带有WITH_OPENCL = ON的CMake配置OpenCV.设置标志后,如果已安装OpenCL SDK,则将构建功能齐全的OpenCV OCL模块.否则,可能无法构建该模块.

因此,我将尝试确保您具有支持它的GPU,然后确保您具有驱动程序(SDK?)在安装OpenCV之前,我实际上首先对OpenCL进行了一些工作,以确保我对它们的工作方式有所了解独立地.

So I would try to make sure you have GPU that supports it and then make sure you have the drivers (SDK?) I actually did some work with OpenCL first before installing OpenCV to make sure I had some understanding of how they worked independently.

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

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