How to know if GPU computing is used in OpenCv4Android native - android

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:
But how to know if openCv is really using OpenCl for acceleration or not ?

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.

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.

Related

running openCL in android

Well there are many tutorials and post about this, but I am not getting exactly how to deal with libOpenCL.so file. Many vendors does not include it inside phone, but my app needs to support maximum available phones today, so do I need to get compatible libOpenCL.so file for each of them?
OpenCL is not officially supported by Android Open Source Project
See: Why did Google choose RenderScript instead of OpenCL
However it appears that Device Manufacturers are including support by adding in the driver.
See: Does Android support OpenCL?
Realize that OpenCL is at a similar layer in the hardware stack as the graphics driver and any particular implementation will depend on the manufacturer and would be specific to that device. You can't just take a libOpenCL.so from one ARM64 device and expect to work for another due to system-on-a-chip specific customizations (number of cores, DSPs, GPUs etc.)
My recommendation from: C++, OpenCV and "what" for cross-platform GPU programing
If you want maximum support - stick to C/C++ code.
If you need OpenCL to make your app performant even with parallelized code, your option is to check if the library is there and warn the user about the lack of support. Ideally then fall back to the parallelized code on those devices without OpenCL.
Until Google makes OpenCL part of the Android Compatibility Definition Document and requires some metadata property, only by the app checking on the device can the app know that OpenCL is even available.
Adding to the answer of #Morrison Chang:
You can not rely on all version of OpenCL in all devices to have everything supported. So I would do a dinamic library loading, and query at runtime for the OpenCL methods are available.
Regarding the library with OpenCL support, sometimes is not even called like that. For example libGLESmali.so has OpenCL symbols and can be used directly.

Setting up OpenGL ES 1.1, and my android environment

This may be a bit difficult, but I have a fairly complex question:
I'm fixing up an old Android phone I have from 2010 (very crap phone), to play with and experiment on. I want to write some OpenGL ES 1.1 programs (preferably in C) on it, but I have no idea how to set up my development environment.
Specifically, my question is this:
How can I set up my android device to run C code, and then link OpenGL ES 1.1 with it?
Would it be better to replace the OS (Android 2.1) with Ubuntu (or something else entirely)? I'm not sure it could run it very well, but it might simplify the process of getting the C code on it since I can just compile with GCC and run.
I've never really done something like this on a phone before (I've dabbled in the Java side of android), so any advice is appreciated.
Thanks!
You will need to setup your device to be able to deploy and debug with your system, which varies from device to device. If you've already got development in Java working on the device, then you shouldn't need to do anything additional to the setup device to develop in C/C++.
For your development machine, you will need to install at a bare-minimum the NDK. The NDK is also bundled as a package from several other sources, such as in the Tegra Android Developer's Pack, and now also Visual Studio 2015 RC. Which package you choose for development is a matter of preference.
In terms of developing for GLES 1.1, as far as I know, there are not any 'official' samples for developing for it, however, there are several tutorials around. In the NDK, you will need to #include <GLES/gl.h> to get the API. You can then take a look at Khronos' specifications on its usage.

How to enable software rendering in lollipop?

I am working on an Android project where my device need to run by using software rendering.
My device architecture is ARM and I want to run lollipop using software rendering as my device dont have compatible hardware library file.
I came across that we need to set the flag USE_OPENGL_RENDERER to flase.
After setting also i am not getting the display ie getting android logo but not booting further.
What are the exact changes that i need to do in the source code to make it work with software rendering
I don't think Android supports devices without OpenGL for a while.
Android Compatibility Definition Document (CDD)
7.1.4. 2D and 3D Graphics Acceleration
Device implementations MUST support both OpenGL ES 1.0 and 2.0, as embodied and detailed in the Android SDK
documentations.

Building an Irrlicht Game Engine C++ library with CCTools on android device without NDK

My question is - is it possible to compile a C++ library that uses some desktop features on mobile device - in this particular case the Irrlicht Engine? I know there is a port out there that uses OGLES drivers, but it also combines using the NDK. I would like to know if there is a possibility to build that library with such a tool like CCTools despite the fact that mobile devices use OpenGL ES - maybe some kind of equivalent libraries, that fit both mobile and desktop environments? There may be some incompatibilities, I know.
The system of input and output doesn't matter at the moment.
And of course - I haven't found the question that fits my expectations.
I wrote an article about porting desktop OpenGL apps to Android that might help:
http://software.intel.com/en-us/articles/porting-opengl-games-to-android-on-intel-atom-processors-part-1
I don't see the advantage of using CCTools rather than the NDK. I think the differences between OpenGL and OpenGL ES would be the biggest problem.

Can the Android phone use the windows DirectX library?

I have some functions which draws the game screen using the Direct X library in Windows.
So, I am trying to use the functions in Android phone using the ndk.
But I have some problems. Dose the Android phone which use the Java recognize the Direct X functions? If it is possible, then I must have some controls about it?
I want your help...
Android (and iOS as well) doesn't support DirectX but OpenGL ES. Check out 3D with OpenGL on the Android developer site.
Android uses a linux kernel, not a windows one. So I'd suspect no.
OpenGL is pretty similar to DirectX it doesn't take too much effort to convert between the 2. Failing that you could probably find the implementation in the Wine source code on how they handle DirectX calls and pass them to OpenGL.
No, because Android is based on Linux Kernel, whch supports OpenGL.

Categories

Resources