1

I want to speed up my programs by using Transparent API. To test if there is a improvement in speed, I tried to use UMat instead of Mat. Doing that, however, is way slower than using Mat on my Laptop. I'm using Ubuntu 16.04. My GPU is an Intel Ivybridge [8086:0166] (http://www.thinkwiki.org/wiki/Intel_HD_Graphics). CPU: Intel® Core™ i5-3320M CPU @ 2.60GHz × 4. I'm using OpenCV 3.2.0 (on Qt 5.9.1) and installed it by:

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

I followed this guide to install OpenCL on my machine: https://askubuntu.com/questions/850281/opencl-on-ubuntu-16-04-intel-sandy-bridge-cpu . I was able to run the OpenCL test code from the website and "clinfo" in terminal works, too.

I also enabled IPP as described here: https://software.intel.com/en-us/articles/enabling-ipp-on-opencv-windows-and-linux-ubintu

Moreover, I tried it without IPP and by playing around with the cmake configuration, which didn't change anything.

I used the following code to determine the speed:

#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;
}

The output is 4442085 (4,4 seconds). Using Mat (by changing UMat to Mat and using img = imread("/home/robin/Pictures/Lenna.png", 1);) the time is 2628712.

I have really no idea what I'm doing wrong here. I'm very grateful for every kind of help. Thank you!

Robin
  • 11
  • 2

0 Answers0