Ask Your Question

babak12345's profile - activity

2020-08-25 06:43:06 -0600 received badge  Popular Question (source)
2019-11-04 17:10:29 -0600 asked a question Field to load .pb file

Field to load .pb file I want to load .pb file (protocol buffer file of tensorflow) using code shown below: ReadNetFrom

2017-01-11 16:48:21 -0600 commented question opencv performance in using opencl

How can I check my environmental variables are set correctly?

2017-01-11 16:35:59 -0600 commented question opencv performance in using opencl

It is amazing! I get result like yours using EmguCV

2017-01-11 15:47:45 -0600 asked a question opencv performance in using opencl

I'm programming in C++ using OpenCV 3.1.0. Also I'm new in OpenCV. I want to use OpenCL. Here is my code:

int _tmain(int argc, _TCHAR* argv[])
{
    clock_t t1, t2;
    Mat image;
    image = imread("...//myPic.jpg", CV_LOAD_IMAGE_GRAYSCALE);   // Read the file
    UMat u = image.getUMat(ACCESS_FAST);

    // calculating time with OpenCL
    cv::ocl::setUseOpenCL(true);
    t1 = clock();
    for (int i = 0; i < 1000; i++)
    {
        cv::Canny(u, u, 100, 50);
    }
    t2 = clock();

    // showing time with OpenCL
    double diff = ((double)t2 - (double)t1) / CLOCKS_PER_SEC;
    cout << "Running time with OpenCL: " << diff << endl;

    /////////////////////////////////////////////////////

    // calculating time with OpenCL
    cv::ocl::setUseOpenCL(false);
    t1 = clock();
    for (int i = 0; i < 1000; i++)
    {
        cv::Canny(u, u, 100, 50);
    }
    t2 = clock();

    // showing time with OpenCL
    diff = ((double)t2 - (double)t1) / CLOCKS_PER_SEC;
    cout << "Running time without OpenCL: " << diff << endl;

    getchar();

    return 0;
}

Here is the result of running code in my laptop.

Running time with OpenCL: 5.565
Running time without OpenCL: 2.441

As it is expected first value must be less than second one significantly but it is not. I test OpenCl technology using EmguCV 3.1 ( it is a wrapper for opencv) in C# and the result test show that it is 40 times faster than when I do not use OpenCl.

System info: Windows 8.1
Core i7 2.2GHz (2670QM)
Amd Radeon Graphic card (HD 6700M)
8GB RAM

Why the time with OpenCL is not what It should be expected?