Linux/OSX/Android/iOS | Windows |
---|---|
UPDATE: In addition to the original build notes below, CMake support has been added via the Hunter package manager with cross platform toolchains provided by Polly. See the README pages of these links for details.
- fast and portable C++ code
- platform optimizations for fast texture access
- on iOS: Core Video Texture Cache API
- on Android: EGL pixelbuffers and KHRImage extensions
- well documented
- contains several example applications
LGPLApache 2 licensed
See the project page on my personal website for some more information and possible use-cases for this library.
- iOS 7.1 to 8.2
- Android 4.2 to 5.0
- Apple iPad 2
- Apple iPad 4
- Apple iPad Mini 2
- Apple iPhone 4
- Apple iPhone 4s
- XCode Simulator
- Google Nexus 10 (2013)
These examples should run out-of-the-box using XCode:
- OGLESGPGPUStillImage - Simple project that performs GPU-powered adaptive thresholding on different images
- OGLESGPGPUVideoCam - Project that shows real-time GPU-powered image processing on video camera frames
These projects were created with the Eclipse ADT and use the Android NDK. Instead of Eclipse, you can also use Apache Ant to compile the projects (see below). The following example projects are available:
- OGStillImageDroid - Simple project that performs GPU-powered adaptive thresholding on different images
- OGVideoProcDroid - GPGPU based image processing of live camera frames
To compile, you need to install the Android NDK first.
You should install the Eclipse C/C++ Development Tools (CDT). Then, do the following: Right click on the project in Eclipse, select Properties > C/C++ Build > Environment. Edit the variable NDK_PATH to point to your NDK root directory. You can now compile and run the project via Eclipse.
- go to the example project directory
- run
android list targets
to find out the Android target ID - run
android update project --target <TARGET_ID> --path . --name "<PROJECT_NAME>"
- run
ndk-build && ant debug
to compile the native sources and create the project's APK file - run
adb -d install bin/<PROJECT_NAME>-debug.apk
to install the APK file on your Android device
You can now run the example application!
You have two options to integrate the library into your project:
- Simply drag & drop the ogles_gpgpu.xcodeproj from the
xcode
folder into your project - In your project, go to the Build Phases tab of your target. Under Link Binary With Libraries add libogles_gpgpu.a
- Include the header file
ogles_gpgpu/ogles_gpgpu.h
into your project's sources
- Simply drag & drop the ogles_gpgpu library sources to your project
- Delete references to Android specific sources so that they won't be compiled (under
platform/android
) - Include the header file
ogles_gpgpu/ogles_gpgpu.h
into your project's sources
- You need to install and set up the Android NDK first. It is also recommended to install the Eclipse C/C++ Development Tools (CDT).
- In your Android project directory, create a folder
jni
. Then copy or link the filesog_jni_wrapper.h
andog_jni_wrapper.cpp
from ogles_gpgpu'sjni_wrapper
folder to thejni
folder of your Android project. - Copy
jni_wrapper/og_pipeline.template.h
andjni_wrapper/og_pipeline.template.cpp
to yourjni
folder and rename them toog_pipeline.h
andog_pipeline.cpp
, respectively. This where you can later define the image processing pipeline. For now, leave it as it is. - Copy
jni_wrapper/Android.template.mk
andjni_wrapper/Application.template.mk
to yourjni
folder and rename them toAndroid.mk
andApplication.mk
, respectively. EditAndroid.mk
and set the proper path to the ogles_gpgpu source in the variableOG_SRC_PATH
. - Try compiling the native sources by executing
ndk-build
in your Android project base directory. This should already succeed and the createdlibog_jni_wrapper.so
library files will be copied tolibs/
. - In your Android project directory, create a folder
src/ogles_gpgpu
. This is where theOGJNIWrapper
Java source will reside. So link or copyjni_wrapper/ogles_gpgpu/OGJNIWrapper.java
tosrc/ogles_gpgpu
. - In Eclipse, refresh your project sources (by pressing F5).
- In your project's Java source, you can now import
ogles_gpgpu.OGJNIWrapper
and use this class to set up an run ogles_gpgpu. See the Android examples on how to do that.
You are ready to go now, basically. However, each time you change something on the C/C++ side of your code (which means everything in the jni
folder), you will need to call ndk-build
manually from the command line. The following describes how to set up Eclipse for C/C++ development, which makes the C/C++ workflow a lot easier. However, you need to install the Eclipse CDT first.
- In Eclipse, select File > New > Other and then select Convert to C/C++ project (don't be afraid, you will still be able to develop in Java, too!). Press Next and select C++ project. Under project options set Makefile Project > Toolchains: Other Toolchain. Do not use Android GCC here!
- Open your project Properties. Under Properties > C/C++ Build > Environment, add the variable NDK_PATH and set it to point to your NDK root directory.
- Still in your project Properties, under Properties > C/C++ Build in the Builder Settings tab, uncheck Use default build command. Instead, set the Build command to
${NDK_PATH}/ndk-build
. In the Behaviour tab delete theall
value in the Build (Incremental build) field. This field needs to be empty. - Yet still in your project Properties, under Properties > C/C++ General > Paths and Symbols, press Add... in the Includes tab. Set the directory value to
${NDK_PATH}/platforms/android-21/arch-arm/usr/include
. Now CDT knows where to look for Android-NDK-specific header files. Press Add... again and set the directory to the path where your ogles_gpgpu source resides. In the Symbols tab add two symbols:ANDROID
and__ANDROID__
(only the names, no value). - Yet still in your project Properties, under Properties > C/C++ General > Preprocessor Include Paths, etc. go to the Providers tab and select CDT GCC Built-In Compiler Settings. After that, press OK and make sure the code analyzer's index will be rebuilt.
Now you are better suited for C++ development on Android. When you start the Run command in Eclipse, the C++ sources will be automatically compiled via ndk-build
. Check the Console output for details. Furthermore, the CDT code analyzer (CODAN) helps editing C++ code with auto-suggestions, warnings, errors, etc. However, sometimes CODAN fails properly analyzing the code and will display errors, although ndk-build
succeeds. You will have to manually delete the errors in the Problems tab then.
- When using platform optimizations on Android (which enables using the ImageKHR extension), the first processing run will not produce any output (the buffer will only contain zeros). However, any successive runs will work normally.
- The "OGStillImageDroid" example application crashes when switching the screen off and on again. This is because
ogWrapper.init()
will try to initialize EGL again inonResume()
, but this only works when the application was send to background and resumed again
- test ipad3
- rasp pi port
- make some comparisons with CPU based image processing (OpenCV as reference)
- AR support (include into ocv_ar)
- more dynamic filters (-> shader code generator)
- create own multipass filter (multiple gauss filters?)
- native iOS YUV input support
This project is licensed under Apache 2 licensed. See LICENSE
file for the full text.