Android Gpuimage Plus

Android Image & Camera Filters Based on OpenGL.
Alternatives To Android Gpuimage Plus
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Gpuimage19,733
7823 years ago9July 14, 2015991bsd-3-clauseObjective-C
An open source iOS framework for GPU-based image and video processing
Cameraview4,682
2 months ago2October 27, 202187otherJava
📸 A well documented, high-level Android interface that makes capturing pictures and videos easy, addressing all of the common issues and needs. Real-time filters, gestures, watermarks, frame processing, RAW, output of any size.
Gpuimage24,674
52 years ago2October 22, 2018195bsd-3-clauseSwift
GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
Androidcamera2,601
3 months ago44Java
🔥🔥🔥自定义Android相机(仿抖音 TikTok),其中功能包括视频人脸识别贴纸,美颜,分段录制,视频裁剪,视频帧处理,获取视频关键帧,视频旋转,添加滤镜,添加水印,合成Gif到视频,文字转视频,图片转视频,音视频合成,音频变声处理,SoundTouch,Fmod音频处理。 Android camera(imitation Tik Tok), which includes video editor,audio editor,video face recognition stickers, segment recording,video cropping, video frame processing, get the first video frame, key frame, video rotation, add filter Mirror ,add watermark ,add gif to video, add text to video, picture to video, audio and video synthesis, audio change processing, SoundTouch, Fmod audio processing.
Android Gpuimage Plus1,705
a month ago315mitC
Android Image & Camera Filters Based on OpenGL.
Matcaps1,690
8 months ago2JavaScript
Huge library of matcap PNG textures organized by color
Androidopengldemo1,678
5 years ago4Java
Android OpenGL ES从零开始的Demo
Pyrender1,0431295 months ago43February 18, 2021143mitPython
Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
Android Opengl Canvas989
8 months ago20apache-2.0Java
An Android library that provides views using openGL canvas to draw things on SurfaceView or TextureView.
Rovio871
2 years ago82otherC++
Alternatives To Android Gpuimage Plus
Select To Compare


Alternative Project Comparisons
Readme

Android-GPUImage-Plus

A C++ & Java library for Image/Camera/Video filters. PRs are welcomed.

New Feature

See the image deform demo.

screenshots screenshots

Gradle dependency

allprojects {
    repositories {
        maven {
            // Use github hosted maven repo for now.
            // Will be uploaded to maven central later.
            url 'https://maven.wysaid.org/'
        }
    }
}

//Choose only one of them
dependencies {
    //All arch: armeabi-v7a, arm64-v8a, x86, x86_64 with video module (ffmpeg bundled)
    implementation 'org.wysaid:gpuimage-plus:3.0.0'

    //All arch: armeabi-v7a, arm64-v8a, x86, x86_64 without video module (no ffmpeg)
    implementation 'org.wysaid:gpuimage-plus:3.0.0-min'
}

The jcenter is out of date, please try the source for now. Latest prebuilt versions will be provided soon.

To compile other versions of ffmpeg, see: https://github.com/wysaid/FFmpeg-Android.git

Build

  • Options to know in local.properties:

    • usingCMakeCompile=true: Compile the native library with CMake if set to true. (Default to false, so you can use the prebuilt libs)
    • usingCMakeCompileDebug=true: Compile the native library in Debug Mode if set to true. (Default to false)
    • disableVideoModule=true: Disable the video recording feature(Useful for image only scenarios). The whole jni module size will be very small. (Default to false)
  • Build with Android Studio and CMake: (Recommended)

    • Put usingCMakeCompile=true in your local.properties
    • Open the repo with the latest version of Android Studio
    • Waiting for the initialization. (NDK/cmake install)
    • Done.
  • Using Visual Studio Code: (Requires WSL(Recommended)/MinGW/Cygwin on Windows.)

    • Setup ENV variable ANDROID_HOME to your Android SDK installation directory.
    • Open the repo with Visual Studio Code
    • Press ⌘ + shift + B (Mac) or ctrl + shift + B (Win/Linux), choose the option Enable CMake And Build Project With CMake.
    • Done.
  • Build with preset tasks: (Requires WSL(Recommended)/MinGW/Cygwin on Windows.)

    # define the environment variable "ANDROID_HOME"
    # If using Windows, define ANDROID_HOME in Windows Environment Settings by yourself.
    export ANDROID_HOME=/path/to/android/sdk
    
    # Setup Project
    bash vscode_tasks.sh --setup-project
    
    # Compile with CMake Debug
    bash vscode_tasks.sh --debug --enable-cmake --build
    # Compile with CMake Release
    bash vscode_tasks.sh --release --enable-cmake --build
    
    # Start Demo By Command
    bash vscode_tasks.sh --run
    
  • Build JNI part with ndk-build: (Not recommended)

    export NDK=path/of/your/ndk
    cd folder/of/jni (android-gpuimage-plus/library/src/main/jni)
    
    #This will make all arch: armeabi, armeabi-v7a arm64-v8a, x86, mips
    ./buildJNI
    #Or use "sh buildJNI"
    
    #Try this if you failed to run the shell above
    export CGE_USE_VIDEO_MODULE=1
    $NDK/ndk-build
    
    #If you don't want anything except the image filter,
    #Do as below to build with only cge module
    #No ffmpeg, opencv or faceTracker.
    #And remove the loading part of ffmpeg&facetracker
    $NDK/ndk-build
    
    #For Windows user, you should include the `.cmd` extension to `ndk-build` like this:
    cd <your\path\to\this\repo>\library\src\main\jni
    <your\path\to\ndk>\ndk-build.cmd
    
    #Also remember to comment out these line in NativeLibraryLoader
    //System.loadLibrary("ffmpeg");
    //CGEFFmpegNativeLibrary.avRegisterAll();
    

You can find precompiled libs here: android-gpuimage-plus-libs (The precompiled '.so' files are generated with NDK-r23b)

Note that the generated file "libFaceTracker.so" is not necessary. So just remove this file if you don't want any feature of it.

Manual

1. Usage

Sample Code for doing a filter with Bitmap

//Simply apply a filter to a Bitmap.
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Bitmap srcImage = ...;

    //HSL Adjust (hue: 0.02, saturation: -0.31, luminance: -0.17)
    //Please see the manual for more details.
    String ruleString = "@adjust hsl 0.02 -0.31 -0.17";

    Bitmap dstImage = CGENativeLibrary.filterImage_MultipleEffects(src, ruleString, 1.0f);

    //Then the dstImage is applied with the filter.

    //Save the result image to /sdcard/libCGE/rec_???.jpg.
    ImageUtil.saveBitmap(dstImage);
}

2. Custom Shader Filter

2.1 Write your own filter

Your filter must inherit CGEImageFilterInterfaceAbstract or its child class. Most of the filters are inherited from CGEImageFilterInterface because it has many useful functions.

// A simple customized filter to do a color reversal.
class MyCustomFilter : public CGE::CGEImageFilterInterface
{
public:
    
    bool init()
    {
        CGEConstString fragmentShaderString = CGE_SHADER_STRING_PRECISION_H
        (
        varying vec2 textureCoordinate;  //defined in 'g_vshDefaultWithoutTexCoord'
        uniform sampler2D inputImageTexture; // the same to above.

        void main()
        {
            vec4 src = texture2D(inputImageTexture, textureCoordinate);
            src.rgb = 1.0 - src.rgb;  //Simply reverse all channels.
            gl_FragColor = src;
        }
        );

        //m_program is defined in 'CGEImageFilterInterface'
        return m_program.initWithShaderStrings(g_vshDefaultWithoutTexCoord, s_fsh);
    }

    //void render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID)
    //{
    //  //Your own render functions here.
    //  //Do not override this function to use the CGEImageFilterInterface's.
    //}
};

Note: To add your own shader filter with c++. Please see the demo for further details.

2.2 Run your own filter

In C++, you can use a CGEImageHandler to do that:

//Assume the gl context already exists:
//JNIEnv* env = ...;
//jobject bitmap = ...;
CGEImageHandlerAndroid handler;
CustomFilterType* customFilter = new CustomFilterType();

//You should handle the return value (false is returned when failed.)
customFilter->init();
handler.initWithBitmap(env, bitmap);

//The customFilter will be released when the handler' destructor is called.
//So you don't have to call 'delete customFilter' if you add it into the handler.
handler.addImageFilter(customFilter);

handler.processingFilters(); //Run the filters.

jobject resultBitmap = handler.getResultBitmap(env);

If no gl context exists, the class CGESharedGLContext may be helpful.

In Java, you can simply follow the sample:

See: CGENativeLibrary.cgeFilterImageWithCustomFilter

Or to do with a CGEImageHandler

3. Filter Rule String

Doc: https://github.com/wysaid/android-gpuimage-plus/wiki

En: https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(EN)

Ch: https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(ZH)

Tool

Some utils are available for creating filters: wysaid/cge-tools

Tool

License

MIT License

Donate

Alipay:

Alipay

Paypal:

Paypal

Popular Opengl Projects
Popular Camera Projects
Popular Graphics Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C
Camera
Opengl
Gpuimage