From fbf31f01048368f4ccdf7c4f918e99e035120999 Mon Sep 17 00:00:00 2001 From: WangQiang Date: Thu, 4 Aug 2022 20:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 28 ++++++++- mediapipe/render/core/BUILD | 6 ++ mediapipe/render/core/Context.cpp | 9 ++- mediapipe/render/core/Context.hpp | 5 +- mediapipe/render/core/GPUImageUtil.cpp | 5 +- mediapipe/render/core/GaussianBlurFilter.cpp | 2 +- .../render/core/GaussianBlurMonoFilter.cpp | 1 - mediapipe/render/core/dispatch_queue.cpp | 2 +- mediapipe/render/module/beauty/BUILD | 10 ++- .../android/framework/AndroidManifest.xml | 9 --- .../beauty/android/framework/jni_hooks.cpp | 11 ---- .../android/framework/rbga_2_yuv_frag.frag | 63 ------------------- .../android/framework/rgba_2_yuv_vertex.vert | 11 ---- mediapipe/render/module/common/BUILD | 3 +- 14 files changed, 54 insertions(+), 111 deletions(-) delete mode 100644 mediapipe/render/module/beauty/android/framework/AndroidManifest.xml delete mode 100644 mediapipe/render/module/beauty/android/framework/jni_hooks.cpp delete mode 100644 mediapipe/render/module/beauty/android/framework/rbga_2_yuv_frag.frag delete mode 100644 mediapipe/render/module/beauty/android/framework/rgba_2_yuv_vertex.vert diff --git a/.vscode/settings.json b/.vscode/settings.json index 44fec627d..57e29570f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -75,7 +75,33 @@ "stack": "cpp", "__mutex_base": "cpp", "shared_mutex": "cpp", - "valarray": "cpp" + "valarray": "cpp", + "__bit_reference": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__functional_base": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__node_handle": "cpp", + "__nullptr": "cpp", + "__split_buffer": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__tuple": "cpp", + "algorithm": "cpp", + "codecvt": "cpp", + "fstream": "cpp", + "iomanip": "cpp", + "iterator": "cpp", + "locale": "cpp", + "random": "cpp", + "regex": "cpp", + "cinttypes": "cpp", + "csignal": "cpp", + "memory_resource": "cpp", + "future": "cpp", + "cfenv": "cpp" }, "C_Cpp.errorSquiggles": "Disabled" } \ No newline at end of file diff --git a/mediapipe/render/core/BUILD b/mediapipe/render/core/BUILD index fdd557111..6786e2da7 100644 --- a/mediapipe/render/core/BUILD +++ b/mediapipe/render/core/BUILD @@ -58,6 +58,12 @@ cc_library( srcs = ["GPUImageUtil.cpp"], hdrs = ["GPUImageUtil.h"], visibility = ["//path/to/package:__pkg__"], + linkopts = select({ + "//conditions:default": [], + "//mediapipe:android": [ + "-llog", + ], + }), deps = select({ "//mediapipe:android": [], "//mediapipe:apple": [], diff --git a/mediapipe/render/core/Context.cpp b/mediapipe/render/core/Context.cpp index c7decf7e5..26d79fba9 100755 --- a/mediapipe/render/core/Context.cpp +++ b/mediapipe/render/core/Context.cpp @@ -23,6 +23,7 @@ #import #endif + #include "Filter.hpp" #include "Context.hpp" #include "GPUImageUtil.h" @@ -34,6 +35,7 @@ std::mutex Context::_mutex; std::string Context::activatedContextKey = ""; std::map Context::_ContextCache; +#if defined(__APPLE__) Context::Context(EAGLContext *context) :_curShaderProgram(0) ,isCapturingFrame(false) @@ -44,16 +46,13 @@ Context::Context(EAGLContext *context) ,_eglContextIO(0) ,vertexArray(-1) { _framebufferCache = new FramebufferCache(this); - -#if defined(__APPLE__) - _eglContext = context; shareGroup = [_eglContext sharegroup]; _eglContextIO = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3 sharegroup:shareGroup]; _eglOfflinerenderContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3 sharegroup:shareGroup]; - -#endif } +#endif + Context::Context() :_curShaderProgram(0) diff --git a/mediapipe/render/core/Context.hpp b/mediapipe/render/core/Context.hpp index 593a5732c..49fe716b0 100755 --- a/mediapipe/render/core/Context.hpp +++ b/mediapipe/render/core/Context.hpp @@ -30,8 +30,9 @@ #import #import #import -#else -#include +#elif defined(__ANDROID__) +#include +#include #endif diff --git a/mediapipe/render/core/GPUImageUtil.cpp b/mediapipe/render/core/GPUImageUtil.cpp index b0363ecd0..f27d45f23 100755 --- a/mediapipe/render/core/GPUImageUtil.cpp +++ b/mediapipe/render/core/GPUImageUtil.cpp @@ -17,11 +17,14 @@ */ #if defined(__APPLE__) #import +#elif defined(__ANDROID__) +#include #endif + #include "GPUImageUtil.h" #define openLog 1 - +#define ANDROID_LOG_INFO 'gpu_log_info' namespace Opipe { diff --git a/mediapipe/render/core/GaussianBlurFilter.cpp b/mediapipe/render/core/GaussianBlurFilter.cpp index 7ef0f723c..dfcbc51ad 100755 --- a/mediapipe/render/core/GaussianBlurFilter.cpp +++ b/mediapipe/render/core/GaussianBlurFilter.cpp @@ -18,7 +18,7 @@ #include #include "GaussianBlurFilter.hpp" -#include "util.h" +// #include "util.h" NS_GI_BEGIN diff --git a/mediapipe/render/core/GaussianBlurMonoFilter.cpp b/mediapipe/render/core/GaussianBlurMonoFilter.cpp index 6bda774a8..99db83064 100755 --- a/mediapipe/render/core/GaussianBlurMonoFilter.cpp +++ b/mediapipe/render/core/GaussianBlurMonoFilter.cpp @@ -18,7 +18,6 @@ #include #include "GaussianBlurMonoFilter.hpp" -#include "util.h" NS_GI_BEGIN diff --git a/mediapipe/render/core/dispatch_queue.cpp b/mediapipe/render/core/dispatch_queue.cpp index fd099fcca..1c490bc39 100755 --- a/mediapipe/render/core/dispatch_queue.cpp +++ b/mediapipe/render/core/dispatch_queue.cpp @@ -13,7 +13,7 @@ #if defined(__APPLE__) #include "GPUImageMacros.h" #else -#include "GPUImage-x/GPUImageMacros.h" +#include "GPUImageMacros.h" #endif #if defined(__APPLE__) #include diff --git a/mediapipe/render/module/beauty/BUILD b/mediapipe/render/module/beauty/BUILD index 134bc4b44..0b1bed14d 100644 --- a/mediapipe/render/module/beauty/BUILD +++ b/mediapipe/render/module/beauty/BUILD @@ -44,15 +44,19 @@ cc_library( linkstatic = True, deps = [ "//mediapipe/render/module/common:olamodule_common_library", - - ] + select({ "//mediapipe:apple": [ "//mediapipe/render/core:core-ios", "//mediapipe/graphs/face_mesh:mobile_calculators", "//mediapipe/framework/formats:landmark_cc_proto", "//mediapipe/render/module/beauty/filters:BeautyFilters", - ], + ], + "//mediapipe:android": [ + "//mediapipe/render/core:core", + "//mediapipe/graphs/face_mesh:mobile_calculators", + "//mediapipe/framework/formats:landmark_cc_proto", + "//mediapipe/render/module/beauty/filters:BeautyFilters", + ], "//conditions:default": [ "//mediapipe/render/core:core", "//mediapipe/graphs/face_mesh:mobile_calculators", diff --git a/mediapipe/render/module/beauty/android/framework/AndroidManifest.xml b/mediapipe/render/module/beauty/android/framework/AndroidManifest.xml deleted file mode 100644 index 190870960..000000000 --- a/mediapipe/render/module/beauty/android/framework/AndroidManifest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/mediapipe/render/module/beauty/android/framework/jni_hooks.cpp b/mediapipe/render/module/beauty/android/framework/jni_hooks.cpp deleted file mode 100644 index 65fa631be..000000000 --- a/mediapipe/render/module/beauty/android/framework/jni_hooks.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by jormin on 2021/4/3. -// - -#include - -extern "C" { -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { - return JNI_VERSION_1_6; -} -} \ No newline at end of file diff --git a/mediapipe/render/module/beauty/android/framework/rbga_2_yuv_frag.frag b/mediapipe/render/module/beauty/android/framework/rbga_2_yuv_frag.frag deleted file mode 100644 index 8a668a78d..000000000 --- a/mediapipe/render/module/beauty/android/framework/rbga_2_yuv_frag.frag +++ /dev/null @@ -1,63 +0,0 @@ -precision highp float; -precision highp int; -varying vec2 textureCoordinate; -uniform sampler2D inputImageTexture; -uniform float inputImageTextureWidth; -uniform float inputImageTextureHeight; -float cY(float x,float y){ - vec4 c=texture2D(inputImageTexture,vec2(x,y)); - return 0.183 * c.r + 0.614 * c.g + 0.062 * c.b + 0.0625; -} - -vec4 cC(float x,float y,float dx,float dy){ - vec4 c0=texture2D(inputImageTexture,vec2(x,y)); - vec4 c1=texture2D(inputImageTexture,vec2(x+dx,y)); - vec4 c2=texture2D(inputImageTexture,vec2(x,y+dy)); - vec4 c3=texture2D(inputImageTexture,vec2(x+dx,y+dy)); - return (c0+c1+c2+c3)/4.; -} - -float cU(float x,float y,float dx,float dy){ - vec4 c=cC(x,y,dx,dy); - return -0.101 * c.r - 0.339 * c.g + 0.439 * c.b + 0.5000; -} - -float cV(float x,float y,float dx,float dy){ - vec4 c=cC(x,y,dx,dy); - return 0.439 * c.r - 0.399 * c.g - 0.040 * c.b + 0.5000; -} - -vec2 cPos(float t,float shiftx,float gy){ - vec2 pos=vec2(floor(inputImageTextureWidth*textureCoordinate.x),floor(inputImageTextureHeight*gy)); - return vec2(mod(pos.x*shiftx,inputImageTextureWidth),(pos.y*shiftx+floor(pos.x*shiftx/inputImageTextureWidth))*t); -} - -vec4 calculateY(){ - vec2 pos=cPos(1.,4.,textureCoordinate.y); - vec4 oColor=vec4(0); - float textureYPos=pos.y/inputImageTextureHeight; - oColor[0]=cY(pos.x/inputImageTextureWidth,textureYPos); - oColor[1]=cY((pos.x+1.)/inputImageTextureWidth,textureYPos); - oColor[2]=cY((pos.x+2.)/inputImageTextureWidth,textureYPos); - oColor[3]=cY((pos.x+3.)/inputImageTextureWidth,textureYPos); - return oColor; -} -vec4 calculateUV(float dx,float dy){ - vec2 pos=cPos(2.,4.,textureCoordinate.y-0.2500); - vec4 oColor=vec4(0); - float textureYPos=pos.y/inputImageTextureHeight; - oColor[0]= cV(pos.x/inputImageTextureWidth,textureYPos,dx,dy); - oColor[1]= cU(pos.x/inputImageTextureWidth,textureYPos,dx,dy); - oColor[2]= cV((pos.x+2.)/inputImageTextureWidth,textureYPos,dx,dy); - oColor[3]= cU((pos.x+2.)/inputImageTextureWidth,textureYPos,dx,dy); - return oColor; -} -void main() { - if(textureCoordinate.y<0.2500){ - gl_FragColor=calculateY(); - }else if(textureCoordinate.y<0.3750){ - gl_FragColor=calculateUV(1./inputImageTextureWidth,1./inputImageTextureHeight); - }else{ - gl_FragColor=vec4(0,0,0,0); - } -} \ No newline at end of file diff --git a/mediapipe/render/module/beauty/android/framework/rgba_2_yuv_vertex.vert b/mediapipe/render/module/beauty/android/framework/rgba_2_yuv_vertex.vert deleted file mode 100644 index 7510e1936..000000000 --- a/mediapipe/render/module/beauty/android/framework/rgba_2_yuv_vertex.vert +++ /dev/null @@ -1,11 +0,0 @@ - attribute vec4 position; - attribute vec4 inputTextureCoordinate; - uniform mat4 mvp; - - varying vec2 textureCoordinate; - - void main() - { - gl_Position = mvp * position; - textureCoordinate = inputTextureCoordinate.xy; - } \ No newline at end of file diff --git a/mediapipe/render/module/common/BUILD b/mediapipe/render/module/common/BUILD index b9681712c..028ff14ed 100644 --- a/mediapipe/render/module/common/BUILD +++ b/mediapipe/render/module/common/BUILD @@ -36,13 +36,12 @@ cc_library( "//mediapipe/objc:util", ], }), - copts = select({ + copts = select({ "//mediapipe:apple": [ "-x objective-c++", "-Wno-shorten-64-to-32", "-fobjc-arc", # enable reference-counting ], - "//conditions:default": ["-std=c++17"], }), alwayslink = True,