2

I am programming a native app on Android using Opencv4Android. I am using the Opencv Manager. At the staup of the app, I receive these logs: enter image description here

But how to know if openCv is really using OpenCl for acceleration or not ?

VAndrei
  • 5,420
  • 18
  • 43
MadMax007
  • 63
  • 4

2 Answers2

0

Unfortunately Google dropped OpenCL support for Android, for quite a while. This was done in favor of RenderScript.

So the first thing to do is to check your OpenCL availability on your platform. You could use OpenCL-Z. The tool will likely tell you if OpenCL runtime is present and if it can use both the GPU and the CPU.

The fact that OpenCV4Android is compiled with OpenCL support means that you can use the OpenCL specific namespaces. So if your platform has OpenCL, and in your code you use OpenCL specific objects (e.g. oclMat) your native code will use OpenCL.

Finally, you cannot be sure what OpenCL device (GPU / CPU) will be used by the OpenCV implementation. You can browse through the source of OpenCV and see the specific implementation for your kernels, or you could use the system profilers that are available for your Android device, and watch for GPU and CPU activity.

VAndrei
  • 5,420
  • 18
  • 43
  • 1
    One way to tell is that try changing the name of the OpenCL dynamic library name (such as libOpenCL.so on a Qualcomm chip device). If the APP was running pretty well, but now it crashes, it means that the APP is using the OpenCL. – Robert Wang Mar 08 '16 at 10:06
0

Thanks to VAndrei, I am now sure that I was not using OpenCL. I was not using the ocl package. Moreover I then tried the ocl package but I got an error at running at the first ocl code line. Then I checked with OpenCl-z and it seems that OpenCL is not available on the device (Rk3188).

I am quite surprised by the performance of the system (ARM Cortex-A9). For these lines, with a resolution of 160x120 on grayscale:

    cv::absdiff(_inputMat, _previousMat, _outputMat);
    _inputMat.copyTo(_previousMat);
    cv::GaussianBlur(_outputMat, _outputMat, cv::Size(3,3), 2.0, 2.0);
    cv::threshold(_outputMat, _outputMat, 100, 255, 0);

the system requires ~1.5ms. That is why I was wondering if OpenCl was used or not. Seems that Rk3288 is supporting OpenCl. I will have to check the improvements on htis other system.

MadMax007
  • 63
  • 4