openGL ES美颜滤镜之美白,磨皮,红润[通俗易懂]

openGL ES美颜滤镜之美白,磨皮,红润[通俗易懂]下面是滤镜源码:importandroid.app.Activity;importandroid.content.Context;importandroid.graphics.Bitmap;importandroid.opengl.GLES20;importandroid.opengl.GLSurfaceView;importandroid.opengl.Matrix;importandroid.view.WindowManager;importcom.ws.gl.o

大家好,又见面了,我是你们的朋友全栈君。

下面是滤镜源码:


import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import android.view.WindowManager;

import com.ws.gl.opengltexture.programs.TextureShaderProgram;
import com.ws.gl.opengltexture.util.GLBitmapUtils;
import com.ws.gl.opengltexture.util.MatrixHelper;
import com.ws.gl.opengltexture.util.TextureHelper;
import com.ws.ijk.openglpicture.R;

import java.nio.FloatBuffer;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;



public class BeautyRenderer implements GLSurfaceView.Renderer{

    public static final String VERTEX_SHADER = "" +
            "attribute vec4 vPosition;\n" +
            "uniform mat4 vMatrix;\n"+
            "attribute vec2 vCoordinate;\n" +
            " \n" +
            "varying vec2 textureCoordinate;\n" +
            " \n" +
            "void main()\n" +
            "{\n" +
            "    gl_Position =vMatrix* vPosition;\n" +
            "    textureCoordinate = vCoordinate;\n" +
            "}";

    public static final String BILATERAL_FRAGMENT_SHADER = "" +
            "precision highp float;\n"+
            "   varying highp vec2 textureCoordinate;\n" +
            "\n" +
            "    uniform sampler2D vTexture;\n" +
            "\n" +
            "    uniform highp vec2 singleStepOffset;\n" +
            "    uniform highp vec4 params;\n" +
            "    uniform highp float brightness;\n" +
            "    uniform float texelWidthOffset;\n"+
            "    uniform float texelHeightOffset;\n"+
            "\n" +
            "    const highp vec3 W = vec3(0.299, 0.587, 0.114);\n" +
            "    const highp mat3 saturateMatrix = mat3(\n" +
            "        1.1102, -0.0598, -0.061,\n" +
            "        -0.0774, 1.0826, -0.1186,\n" +
            "        -0.0228, -0.0228, 1.1772);\n" +
            "    highp vec2 blurCoordinates[24];\n" +
            "\n" +
            "    highp float hardLight(highp float color) {\n" +
            "    if (color <= 0.5)\n" +
            "        color = color * color * 2.0;\n" +
            "    else\n" +
            "        color = 1.0 - ((1.0 - color)*(1.0 - color) * 2.0);\n" +
            "    return color;\n" +
            "}\n" +
            "\n" +
            "    void main(){\n" +
            "    highp vec3 centralColor = texture2D(vTexture, textureCoordinate).rgb;\n" +
            "    vec2 singleStepOffset=vec2(texelWidthOffset,texelHeightOffset);\n"+
            "    blurCoordinates[0] = textureCoordinate.xy + singleStepOffset * vec2(0.0, -10.0);\n" +
            "    blurCoordinates[1] = textureCoordinate.xy + singleStepOffset * vec2(0.0, 10.0);\n" +
            "    blurCoordinates[2] = textureCoordinate.xy + singleStepOffset * vec2(-10.0, 0.0);\n" +
            "    blurCoordinates[3] = textureCoordinate.xy + singleStepOffset * vec2(10.0, 0.0);\n" +
            "    blurCoordinates[4] = textureCoordinate.xy + singleStepOffset * vec2(5.0, -8.0);\n" +
            "    blurCoordinates[5] = textureCoordinate.xy + singleStepOffset * vec2(5.0, 8.0);\n" +
            "    blurCoordinates[6] = textureCoordinate.xy + singleStepOffset * vec2(-5.0, 8.0);\n" +
            "    blurCoordinates[7] = textureCoordinate.xy + singleStepOffset * vec2(-5.0, -8.0);\n" +
            "    blurCoordinates[8] = textureCoordinate.xy + singleStepOffset * vec2(8.0, -5.0);\n" +
            "    blurCoordinates[9] = textureCoordinate.xy + singleStepOffset * vec2(8.0, 5.0);\n" +
            "    blurCoordinates[10] = textureCoordinate.xy + singleStepOffset * vec2(-8.0, 5.0);\n" +
            "    blurCoordinates[11] = textureCoordinate.xy + singleStepOffset * vec2(-8.0, -5.0);\n" +
            "    blurCoordinates[12] = textureCoordinate.xy + singleStepOffset * vec2(0.0, -6.0);\n" +
            "    blurCoordinates[13] = textureCoordinate.xy + singleStepOffset * vec2(0.0, 6.0);\n" +
            "    blurCoordinates[14] = textureCoordinate.xy + singleStepOffset * vec2(6.0, 0.0);\n" +
            "    blurCoordinates[15] = textureCoordinate.xy + singleStepOffset * vec2(-6.0, 0.0);\n" +
            "    blurCoordinates[16] = textureCoordinate.xy + singleStepOffset * vec2(-4.0, -4.0);\n" +
            "    blurCoordinates[17] = textureCoordinate.xy + singleStepOffset * vec2(-4.0, 4.0);\n" +
            "    blurCoordinates[18] = textureCoordinate.xy + singleStepOffset * vec2(4.0, -4.0);\n" +
            "    blurCoordinates[19] = textureCoordinate.xy + singleStepOffset * vec2(4.0, 4.0);\n" +
            "    blurCoordinates[20] = textureCoordinate.xy + singleStepOffset * vec2(-2.0, -2.0);\n" +
            "    blurCoordinates[21] = textureCoordinate.xy + singleStepOffset * vec2(-2.0, 2.0);\n" +
            "    blurCoordinates[22] = textureCoordinate.xy + singleStepOffset * vec2(2.0, -2.0);\n" +
            "    blurCoordinates[23] = textureCoordinate.xy + singleStepOffset * vec2(2.0, 2.0);\n" +
            "\n" +
            "    highp float sampleColor = centralColor.g * 22.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[0]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[1]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[2]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[3]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[4]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[5]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[6]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[7]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[8]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[9]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[10]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[11]).g;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[12]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[13]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[14]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[15]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[16]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[17]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[18]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[19]).g * 2.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[20]).g * 3.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[21]).g * 3.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[22]).g * 3.0;\n" +
            "    sampleColor += texture2D(vTexture, blurCoordinates[23]).g * 3.0;\n" +
            "\n" +
            "    sampleColor = sampleColor / 62.0;\n" +
            "\n" +
            "    highp float highPass = centralColor.g - sampleColor + 0.5;\n" +
            "\n" +
            "    for (int i = 0; i < 5; i++) {\n" +
            "        highPass = hardLight(highPass);\n" +
            "    }\n" +
            "    highp float lumance = dot(centralColor, W);\n" +
            "\n" +
            "    highp float alpha = pow(lumance, params.r);\n" +
            "\n" +
            "    highp vec3 smoothColor = centralColor + (centralColor-vec3(highPass))*alpha*0.1;\n" +
            "\n" +
            "    smoothColor.r = clamp(pow(smoothColor.r, params.g), 0.0, 1.0);\n" +
            "    smoothColor.g = clamp(pow(smoothColor.g, params.g), 0.0, 1.0);\n" +
            "    smoothColor.b = clamp(pow(smoothColor.b, params.g), 0.0, 1.0);\n" +
            "\n" +
            "    highp vec3 lvse = vec3(1.0)-(vec3(1.0)-smoothColor)*(vec3(1.0)-centralColor);\n" +
            "    highp vec3 bianliang = max(smoothColor, centralColor);\n" +
            "    highp vec3 rouguang = 2.0*centralColor*smoothColor + centralColor*centralColor - 2.0*centralColor*centralColor*smoothColor;\n" +
            "\n" +
            "    gl_FragColor = vec4(mix(centralColor, lvse, alpha), 1.0);\n" +
            "    gl_FragColor.rgb = mix(gl_FragColor.rgb, bianliang, alpha);\n" +
            "    gl_FragColor.rgb = mix(gl_FragColor.rgb, rouguang, params.b);\n" +
            "\n" +
            "    highp vec3 satcolor = gl_FragColor.rgb * saturateMatrix;\n" +
            "    gl_FragColor.rgb = mix(gl_FragColor.rgb, satcolor, params.a);\n" +
            "    gl_FragColor.rgb = vec3(gl_FragColor.rgb + vec3(brightness));\n" +
            "}";

    private  Context context;
    private TextureShaderProgram textureProgram;
    private int texture;
    private final float[] projectionMatrix = new float[16];
    private final float[] modelMatrix = new float[16];

    private Picture picture;

    public int mWidth,mHeight;
    private float toneLevel;
    private float beautyLevel;
    private float brightLevel;
    private float texelWidthOffset;
    private float texelHeightOffset;

    private int paramsLocation;
    private int brightnessLocation;
    private int singleStepOffsetLocation;
    private int texelWidthLocation;
    private int texelHeightLocation;
    private boolean isTakePicture;



    public BeautyRenderer(Context context) {
        this.context = context;
        texelWidthOffset=texelHeightOffset=2;
        toneLevel = -0.5f; 
        beautyLevel =1.2f; 
        brightLevel =0.47f; 

        WindowManager wm = ((Activity)context).getWindowManager();
        mWidth = wm.getDefaultDisplay().getWidth();
        mHeight = wm.getDefaultDisplay().getHeight();
    }



    @Override
    public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        picture = new Picture();
        textureProgram = new TextureShaderProgram(VERTEX_SHADER,BILATERAL_FRAGMENT_SHADER);
        texture = TextureHelper.loadTexture(context, R.mipmap.liu);


        paramsLocation = GLES20.glGetUniformLocation(textureProgram.getProgram(), "params");
        brightnessLocation = GLES20.glGetUniformLocation(textureProgram.getProgram(), "brightness");
        singleStepOffsetLocation = GLES20.glGetUniformLocation(textureProgram.getProgram(), "singleStepOffset");
        texelWidthLocation = GLES20.glGetUniformLocation(textureProgram.getProgram(), "texelWidthOffset");
        texelHeightLocation = GLES20.glGetUniformLocation(textureProgram.getProgram(), "texelHeightOffset");

    }

    @Override
    public void onSurfaceChanged(GL10 gl10, int width, int height) {
        GLES20.glViewport(0, 0, width,height);

        MatrixHelper.perspectiveM(projectionMatrix,45,(float)width/(float)height,1f,10f);

        Matrix.setIdentityM(modelMatrix,0);
        Matrix.translateM(modelMatrix,0,0f,0f,-2.5f);
        //Matrix.rotateM(modelMatrix,0,-60f,1f,0f,0f);
        final float[] temp = new float[16];
        Matrix.multiplyMM(temp,0,projectionMatrix,0,modelMatrix,0);
        System.arraycopy(temp,0,projectionMatrix,0,temp.length);


        setTexelSize(width, height);
        mWidth = width;
        mHeight = height;

    }

    @Override
    public void onDrawFrame(GL10 gl10) {
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        textureProgram.useProgram();
        textureProgram.setUniforms(projectionMatrix,texture);


        setParams(beautyLevel, toneLevel);
        setBrightLevel(brightLevel);
        setTexelOffset(texelWidthOffset);


        picture.bindData(textureProgram);
        picture.draw();

        // 获取GLSurfaceView的图片并保存
        if (isTakePicture) {
           /* Bitmap bmp = GLBitmapUtils.createBitmapFromGLSurface(0, 0, mWidth,
                    mHeight, gl10);*/
            GLBitmapUtils.saveImage(mWidth,mHeight,context);
            isTakePicture = false;
        }

    }

    public void setTexelOffset(float texelOffset) {
        texelWidthOffset=texelHeightOffset=texelOffset;
        setFloat(texelWidthLocation, texelOffset/mWidth);
        setFloat(texelHeightLocation, texelOffset/mHeight);
    }

    public void setToneLevel(float toneLeve) {
        this.toneLevel = toneLeve;
        setParams(beautyLevel, toneLevel);
    }

    public void setBeautyLevel(float beautyLeve) {
        this.beautyLevel = beautyLeve;
        setParams(beautyLevel, toneLevel);
    }

    public void setBrightLevel(float brightLevel) {
        this.brightLevel = brightLevel;
        setFloat(brightnessLocation, 0.6f * (-0.5f + brightLevel));
    }

    public void setParams(float beauty, float tone) {
        this.beautyLevel=beauty;
        this.toneLevel = tone;
        float[] vector = new float[4];
        vector[0] = 1.0f - 0.6f * beauty;
        vector[1] = 1.0f - 0.3f * beauty;
        vector[2] = 0.1f + 0.3f * tone;
        vector[3] = 0.1f + 0.3f * tone;
        setFloatVec4(paramsLocation, vector);
    }

    private void setTexelSize(final float w, final float h) {
        setFloatVec2(singleStepOffsetLocation, new float[] {2.0f / w, 2.0f / h});
    }


   protected void setFloat(final int location, final float floatValue) {
       GLES20.glUniform1f(location, floatValue);
   }
    protected void setFloatVec2(final int location, final float[] arrayValue) {
        GLES20.glUniform2fv(location, 1, FloatBuffer.wrap(arrayValue));
    }

    protected void setFloatVec3(final int location, final float[] arrayValue) {
        GLES20.glUniform3fv(location, 1, FloatBuffer.wrap(arrayValue));
    }

    protected void setFloatVec4(final int location, final float[] arrayValue) {
        GLES20.glUniform4fv(location, 1, FloatBuffer.wrap(arrayValue));
    }

    public void saveImage(){
        isTakePicture =true;
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305

使用:


import android.opengl.GLSurfaceView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.SeekBar;

import com.ws.gl.opengltexture.util.GLBitmapUtils;
import com.ws.ijk.openglpicture.R;

public class BeautyActivity extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener {

    private GLSurfaceView glSurfaceView;
    private BeautyRenderer mRenderer;
    private ImageView mImageView;
    private Button startBtn,saveBtn;
    private boolean isStart=true;


    private SeekBar sb_step,sb_tone,sb_beauty,sb_bright;
    private static float minstepoffset= -10;
    private static float maxstepoffset= 10;
    private static float minToneValue= -5;
    private static float maxToneValue= 5;
    private static float minbeautyValue= 0;
    private static float maxbeautyValue= 2.5f;
    private static float minbrightValue= 0;
    private static float maxbrightValue= 1;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_beauty);

        glSurfaceView= (GLSurfaceView) findViewById(R.id.glView);
        glSurfaceView.setEGLContextClientVersion(2);
        mRenderer =new BeautyRenderer(this);
        glSurfaceView.setRenderer(mRenderer);
        glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

        mImageView= (ImageView) findViewById(R.id.image);
        mImageView.setImageResource(R.mipmap.liu);
        startBtn = (Button) findViewById(R.id.startbtn);
        startBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(isStart){
                    mImageView.setVisibility(View.GONE);

                }else {
                    mImageView.setVisibility(View.VISIBLE);
                }
                isStart = !isStart;
            }
        });

        saveBtn  = (Button) findViewById(R.id.picBtn);
        saveBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mRenderer.saveImage();
                glSurfaceView.requestRender();
            }
        });


        initView();
    }

    private void initView() {
        sb_step = (SeekBar) findViewById(R.id.sb_step);
        sb_step.setOnSeekBarChangeListener(this);
        sb_tone = (SeekBar) findViewById(R.id.sb_tone);
        sb_tone.setOnSeekBarChangeListener(this);
        sb_beauty = (SeekBar) findViewById(R.id.sb_beauty);
        sb_beauty.setOnSeekBarChangeListener(this);
        sb_bright = (SeekBar) findViewById(R.id.sb_bright);
        sb_bright.setOnSeekBarChangeListener(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        glSurfaceView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        glSurfaceView.onResume();
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
              switch (seekBar.getId()){
                  case R.id.sb_step:

                      mRenderer.setTexelOffset(range(progress,minstepoffset,maxstepoffset));
                      break;
                  case R.id.sb_tone:

                      mRenderer.setToneLevel(range(progress,minToneValue,maxToneValue));
                      break;
                  case R.id.sb_beauty:
                    mRenderer.setBeautyLevel(range(progress,minbeautyValue,maxbeautyValue));
                      break;
                  case R.id.sb_bright:

                      mRenderer.setBrightLevel(range(progress,minbrightValue,maxbrightValue));
                      break;
              }
              glSurfaceView.requestRender();
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {

    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {

    }

    protected float range(final int percentage, final float start, final float end) {
        return (end - start) * percentage / 100.0f + start;
    }
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/162981.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Android4.0 input事件输入流程详解(中间层到应用层)

    Android4.0 input事件输入流程详解(中间层到应用层)在Android系统中,类似于键盘按键、触摸屏等事件是由WindowManagerService服务来管理的,然后再以消息的形式来分发给应用程序进行处理。系统启动时,窗口管理服务也会启动,该服务启动过程中,会通过系统输入管理器InputManager来负责监控键盘消息。当某一个Activity激活时,会在该Service下注册一个接收消息的通道,表明可以处理具体的消息,然后当有消息时,InputM

    2022年5月29日
    38
  • NSGA2理解

    NSGA2理解NSGA-II算法学习什么是支配:支配就是统治,在各方面都优于其余个体如个体i支配个体j,就说明个体i在所有目标函数的表现上都不差于个体j,并且至少在一个目标上优于个体j;什么是非支配:非支配就是个体在种群中是最优秀的,它们在该种群中不受其余个体支配。快速非支配排序,将种群中的个体进行分层,最优秀的个体处于第一层,然后除了第一层,再从其余个体中找出非支配个体,以此类推…

    2022年5月19日
    72
  • python 列转行_SQL 行转列,列转行「建议收藏」

    python 列转行_SQL 行转列,列转行「建议收藏」SQL行转列,列转行行列转换在做报表分析时还是经常会遇到的,今天就说一下如何实现行列转换吧。行列转换就是如下图所示两种展示形式的互相转换行转列假如我们有下表:SELECT*FROMstudentPIVOT(SUM(score)FORsubjectIN(语文,数学,英语))通过上面SQL语句即可得到下面的结果PIVOT后跟一个聚合函数来拿到结果,FOR后面跟的科目是我们要…

    2022年6月22日
    53
  • 秒杀多线程第九篇 经典线程同步总结 关键段 事件 互斥量 信号量

    秒杀多线程第九篇 经典线程同步总结 关键段 事件 互斥量 信号量前面《秒杀多线程第四篇一个经典的多线程同步问题》提出了一个经典的多线程同步互斥问题,这个问题包括了主线程与子线程的同步,子线程间的互斥,是一道非常经典的多线程同步互斥问题范例,后面分别用了四篇《秒杀多线程第五篇经典线程同步关键段CS》《秒杀多线程第六篇经典线程同步事件Event》《秒杀多线程第七篇经典线程同步互斥量Mutex》《秒杀多线程第八篇经典线程同步信号量Semaphore》来详细介绍常用的

    2022年7月15日
    14
  • 小米nfc模拟加密门禁卡详细图文教程(实测可用)—————– IC ID CUID卡区别

    小米nfc模拟加密门禁卡详细图文教程(实测可用)—————– IC ID CUID卡区别现在小区虽然都加装了智能门,可以通过手机NFC功能开启或者使用钥匙开启,但是有些用户并不知道原来手机是可以当钥匙使用的。今天我们来学习使用小米nfc模拟加密门禁卡,这样手机就可以变成一把钥匙了。以下是小米nfc模拟加密门禁卡步骤。1、非加密卡直接使用小米钱包的门卡模拟功能即可,如果能直接模拟的就不是加密卡。2、NFC手机支持的频段一般为13.56Mhz卡片,如果是其他门禁卡,手机贴上根本没反应的不可以模拟。3、只能模拟卡片的ID,不支持储值消费等功能。部分门禁等系统只认证卡片ID,所以有可能通过

    2022年5月4日
    254
  • Maven Web报错:org.apache.jasper.JasperException: Unable to compile class for JSP「建议收藏」

    MavenWeb报错:org.apache.jasper.JasperException:UnabletocompileclassforJSP今天被这个问题弄得,拽下了一大把的头发!哭唧唧~~~

    2022年4月6日
    212

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号