您当前的位置: 首页 >  鱼儿-1226

opengl相机通过shader修改片断着色器来实现换色,改色,肤色检测等特殊效果

鱼儿-1226 发布时间:2020-07-22 10:15:46 ,浏览量:6

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

关注
打赏
查看更多评论

鱼儿-1226

暂无认证

  • 6浏览

    0关注

    855博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录