1.嘴唇检测并改掉色,不准确时可能和相同有关,关于嘴唇颜色检测参考文章
https://blog.csdn.net/Trent1985/article/details/46330847
private static final String CAMERA_INPUT_FRAGMENT_SHADER_OES = "" +
"#extension GL_OES_EGL_image_external : require\n" +
"\n" +
"precision mediump float;\n" +
"varying vec2 textureCoordinate;\n" +
"uniform samplerExternalOES inputImageTexture;\n" +
"\n" +
"void main()\n" +
"{\n" +
" vec4 nColor=texture2D(inputImageTexture, textureCoordinate);\n"+
" if (log(nColor.g / (pow(nColor.b, 0.391) * pow(nColor.r, 0.609))) < -0.4)\n"+
" {\n"+
" gl_FragColor = vec4(1.0, 1.0, 1.0, nColor.a);\n"+
" }\n"+
" else\n"+
" {\n" +
" gl_FragColor = nColor;\n"+
" }\n"+
"}";
2.计算高斯模糊
precision mediump float;
//在片元着色器这里添加这个 sampler2D 表示我们要添加2D贴图
uniform sampler2D u_TextureUnit;
varying vec2 v_TextureCoordinates;
void main(){
vec4 color = vec4(0.0);
int coreSize=3;
int halfSize=coreSize/2;
float texelOffset = 0.01;
//创建我们计算好的卷积核
float kernel[9];
kernel[6] = 1.0; kernel[7] = 2.0; kernel[8] = 1.0;
kernel[3] = 2.0; kernel[4] = 4.0; kernel[5] = 2.0;
kernel[0] = 1.0; kernel[1] = 2.0; kernel[2] = 1.0;
int index = 0;
//每一块都进行图像卷积。
for(int y=0;y<coreSize;y++)
{
for(int x = 0;x<coreSize;x++)
{
vec4 currentColor = texture2D(u_TextureUnit,v_TextureCoordinates+vec2(float((-1+x))*texelOffset,float((-1+y))*texelOffset));
color += currentColor*kernel[index];
index++;
}
}
//归一处理
color/=16.0;
gl_FragColor=color;
}
3黑白滤镜
precision mediump float;
//在片元着色器这里添加这个 sampler2D 表示我们要添加2D贴图
uniform sampler2D u_TextureUnit;
//定义一个u_ChangeColor,因为颜色的变量是RGB,所以使用vec3
uniform vec3 u_ChangeColor;
varying vec2 v_TextureCoordinates;
void main(){
//得到2d color
vec4 nColor=texture2D(u_TextureUnit,v_TextureCoordinates);
//黑白图片
float c= nColor.r*u_ChangeColor.r+nColor.g*u_ChangeColor.g+nColor.b*u_ChangeColor.b;
gl_FragColor = vec4(c,c,c,nColor.a);
}
4冷暖色调的处理
与上面的黑白色的处理相似,冷色调的处理就是单一增加蓝色通道的值,暖色调的处理可以增加红绿通道的值。
precision mediump float;
//在片元着色器这里添加这个 sampler2D 表示我们要添加2D贴图
uniform sampler2D u_TextureUnit;
//定义一个u_ChangeColor,因为颜色的变量是RGB,所以使用vec3
uniform vec3 u_ChangeColor;
varying vec2 v_TextureCoordinates;
//modifyColor.将color限制在rgb
void modifyColor(vec4 color){
color.r=max(min(color.r,1.0),0.0);
color.g=max(min(color.g,1.0),0.0);
color.b=max(min(color.b,1.0),0.0);
color.a=max(min(color.a,1.0),0.0);
}
void main(){
//得到2d color
vec4 nColor=texture2D(u_TextureUnit,v_TextureCoordinates);
//简单色彩处理,冷暖色调、增加亮度、降低亮度等
vec4 deltaColor=nColor+vec4(u_ChangeColor,0.0);
modifyColor(deltaColor);
gl_FragColor=deltaColor;
}
5改色
"vec4 nColor=texture2D(inputImageTexture, textureCoordinate);\n"+
"if (nColor.r<0.5 && nColor.g<0.5 && nColor.b<0.5)" +
"{\n"+
" gl_FragColor = vec4(1.0,1.0,1.0,nColor.a);\n" +
"}\n" +
"else\n" +
"{\n"+
" gl_FragColor = texture2D(inputImageTexture, textureCoordinate);\n" +
"}\n"+
参考:
https://blog.csdn.net/qq_33275597/article/details/80869913
https://blog.csdn.net/qq_33275597/article/details/80869913
https://www.jianshu.com/p/320980800358
光照
https://blog.csdn.net/yulinxx/article/details/72720963
https://blog.csdn.net/yulinxx/article/details/53670481
https://cloud.tencent.com/developer/article/1155487
海洋
https://blog.csdn.net/vily_lei/article/details/80919052
相机
https://cloud.tencent.com/developer/article/1175711
相机特效
https://cloud.tencent.com/developer/article/1185194
美颜滤波
https://blog.csdn.net/King1425/article/details/77776931?locationNum=4&fps=1