UMat比Mat慢(OpenCV 3.2,Intel Ivybridge GPU上的TAPI)

时间:2017-10-02 11:40:15

标签: opencv opencl gpu tapi

我想通过使用Transparent API来加速我的程序。为了测试速度是否有所提高,我尝试使用UMat而不是Mat。但是,这样做比在我的笔记本电脑上使用Mat慢。我正在使用Ubuntu 16.04。我的GPU是Intel Ivybridge [8086:0166](http://www.thinkwiki.org/wiki/Intel_HD_Graphics)。 CPU:英特尔®酷睿™i5-3320M CPU @ 2.60GHz×4。我正在使用OpenCV 3.2.0(在Qt 5.9.1上)并通过以下方式安装:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_IPP=ON -D WITH_OPENCL=ON -D WITH_OPENGL=ON .. make -j $(nproc) sudo make install sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' sudo ldconfig

我按照本指南在我的机器上安装OpenCL:https://askubuntu.com/questions/850281/opencl-on-ubuntu-16-04-intel-sandy-bridge-cpu。我能够从网站上运行OpenCL测试代码,并在终端工作中运行“clinfo”。

我还启用了IPP,如下所述:https://software.intel.com/en-us/articles/enabling-ipp-on-opencv-windows-and-linux-ubintu

此外,我尝试了没有IPP并且使用了cmake配置,但没有改变任何内容。

我使用以下代码来确定速度:

#include "opencv2/opencv.hpp"
#include <iostream>
#include <chrono>

using namespace cv;
using namespace std;
using namespace std::chrono;

int main(int argc, char** argv)
{

    UMat img, gray;
    imread("/home/robin/Pictures/Lenna.png", 1).copyTo(img);
    //img = imread("/home/robin/Pictures/Lenna.png", 1);

    high_resolution_clock::time_point t1 = high_resolution_clock::now();

    for(int i = 0; i < 1000; i++) {
        cvtColor(img, gray, COLOR_BGR2GRAY);
        GaussianBlur(gray, gray,Size(7, 7), 1.5);
        Canny(gray, gray, 0, 50);
    }

    high_resolution_clock::time_point t2 = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>( t2 - t1 ).count();
    cout << duration << endl;

    return 0;
}

输出为4442085(4,4秒)。使用Mat(通过将UMat更改为Mat并使用img = imread(“/ home / robin / Pictures / Lenna.png”,1);)时间为2628712。

我真的不知道我在这里做错了什么。我非常感谢各种帮助。谢谢!

0 个答案:

没有答案
相关问题