How to contribute android-gpuimage

107c7e4625bacbe78ee562359d89b318?s=47 Yuji Koketsu
November 16, 2018

How to contribute android-gpuimage

107c7e4625bacbe78ee562359d89b318?s=128

Yuji Koketsu

November 16, 2018
Tweet

Transcript

  1. How to contribute android-gpuimage

  2. About Me Yuji Koketsu @kettsun0123 CATS

  3. android-gpuimageͱ͸ GPUImage2͕΋ͱʹͳ͍ͬͯΔFilterΛ͔͚Δ ϥΠϒϥϦ

  4. ໨࣍ 1. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. ·ͱΊ

  5. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ

  6. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ ࠷΋؆୯ͳContribute͸FilterΛ௥Ճ͢Δ͜ͱ

  7. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ ·ͩ·ͩFilter͕଍Γͳ͍

  8. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ GPUImage2(iOS)ΛࢀߟʹFilterΛ࡞ͬͯPRΛग़͢

  9. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 1. ௥Ճ͢ΔFilterΛܾΊΔ 2. ຊՈGPUImage2ΛࢀߟʹFilterΛ࣮૷͢Δ 3. sampleͰ࡞ͬͨFilterΛ࢖͑ΔΑ͏ʹ͢Δ 4. PRΛग़͢

  10. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 1. ௥Ճ͢ΔFilterΛܾΊΔ README͔ΒબͿ

  11. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ GPUImage2/framework/Source/Operations/Shaders

  12. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture;

    uniform highp float threshold; const highp vec3 W = vec3(0.2125, 0.7154, 0.0721); void main() { highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); highp float luminance = dot(textureColor.rgb, W); highp float thresholdResult = step(luminance, threshold); highp vec3 finalColor = abs(thresholdResult - textureColor.rgb); gl_FragColor = vec4(finalColor, textureColor.w); } Operations/Shaders/Solarize_GLES.fsh
  13. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ public static final String SOLARIZE_FRAGMENT_SHADER = ""

    + "varying highp vec2 textureCoordinate;\n" + "\n" + "uniform sampler2D inputImageTexture;\n" + "uniform highp float threshold;\n" + "\n" + "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" + "\n" + "void main()\n" + "{\n" + " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" + " highp float luminance = dot(textureColor.rgb, W);\n" + " highp float thresholdResult = step(luminance, threshold);\n" + " highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);\n" + " \n" + " gl_FragColor = vec4(finalColor, textureColor.w);\n" + "}"; /filter/GPUImageSolarizeFilter.java
  14. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ public static final String SOLARIZE_FRAGMENT_SHADER = ""

    + "varying highp vec2 textureCoordinate;\n" + "\n" + "uniform sampler2D inputImageTexture;\n" + "uniform highp float threshold;\n" + "\n" + "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" + "\n" + "void main()\n" + "{\n" + " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" + " highp float luminance = dot(textureColor.rgb, W);\n" + " highp float thresholdResult = step(luminance, threshold);\n" + " highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);\n" + " \n" + " gl_FragColor = vec4(finalColor, textureColor.w);\n" + "}"; /filter/GPUImageSolarizeFilter.java ม਺Λ४උ͢Δ
  15. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ /filter/GPUImageSolarizeFilter.java @Override public void onInit() { super.onInit();

    uniformThresholdLocation = GLES20.glGetUniformLocation(getProgram(), "threshold"); }
  16. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ /filter/GPUImageSolarizeFilter.java @Override public void onInitialized() { super.onInitialized();

    setThreshold(threshold); } public void setThreshold(final float threshold) { this.threshold = threshold; setFloat(uniformThresholdLocation, threshold); } ֎෦͔Β஋Λ౉ͤΔΑ͏ʹ͢Δ
  17. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt FilterTypeʹ௥Ճ private enum class FilterType {

    CONTRAST, GRAYSCALE, SHARPEN, SEPIA, SOBEL_EDGE_DETECTION, THRESHOLD_EDGE_DETECTION, THREE_X_THREE_CONVOLUTION, FILTER_GROUP, EMBOSS, …, SOLARIZE }
  18. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ fun showDialog( context: Context, listener: (filter: GPUImageFilter)

    -> Unit ) { val filters = FilterList().apply { addFilter("Contrast", FilterType.CONTRAST) addFilter("Invert", FilterType.INVERT) addFilter("Pixelation", FilterType.PIXELATION) addFilter("Hue", FilterType.HUE) addFilter("Gamma", FilterType.GAMMA) addFilter("Brightness", FilterType.BRIGHTNESS) addFilter("Sepia", FilterType.SEPIA) addFilter("Grayscale", FilterType.GRAYSCALE) … addFilter("Solarize", FilterType.SOLARIZE) } … } sample/GPUImageFilterTools.kt FilterListʹ௥Ճ
  19. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt ࡞ͬͨFilterΛબ୒Ͱ͖ΔΑ͏ʹ private fun createFilterForType(context: Context, type:

    FilterType): GPUImageFilter { return when (type) { FilterType.CONTRAST -> GPUImageContrastFilter(2.0f) FilterType.GAMMA -> GPUImageGammaFilter(2.0f) FilterType.INVERT -> GPUImageColorInvertFilter() FilterType.PIXELATION -> GPUImagePixelationFilter() FilterType.HUE -> GPUImageHueFilter(90.0f) FilterType.BRIGHTNESS -> GPUImageBrightnessFilter(1.5f) FilterType.GRAYSCALE -> GPUImageGrayscaleFilter() FilterType.LEVELS_FILTER_MIN -> GPUImageLevelsFilter() FilterType.HALFTONE -> GPUImageHalftoneFilter() FilterType.BILATERAL_BLUR -> GPUImageBilateralBlurFilter() FilterType.TRANSFORM2D -> GPUImageTransformFilter() … FilterType.SOLARIZE -> GPUImageSolarizeFilter() } }
  20. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ Ϧετʹදࣔ͞ΕΔΑ͏ʹͳΓ·ͨ͠

  21. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ ͜ͷ··Ͱ͸֬ೝͰ͖ͳ͍ͷͰ AdjusterΛ࡞ͬͯFilterͱͯ͠ಈ͔͢

  22. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt AdjusterΫϥεΛ࡞੒ class FilterAdjuster(filter: GPUImageFilter) { …

    private inner class BilateralAdjuster(filter: GPUImageBilateralBlurFilter) : Adjuster<GPUImageBilateralBlurFilter>(filter) { override fun adjust(percentage: Int) { filter.setDistanceNormalizationFactor(range(percentage, 0.0f, 15.0f)) } } … private inner class SolarizeAdjuster(filter: GPUImageSolarizeFilter) : Adjuster<GPUImageSolarizeFilter>(filter) { override fun adjust(percentage: Int) { filter.setThreshold(range(percentage, 0.0f, 1.0f)) } } }
  23. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt ࡞ͬͨAdjusterΛ௥Ճ class FilterAdjuster(filter: GPUImageFilter) { private

    val adjuster: Adjuster<out GPUImageFilter>? init { adjuster = when (filter) { … is GPUImageLevelsFilter -> LevelsMinMidAdjuster(filter) is GPUImageBilateralBlurFilter -> BilateralAdjuster(filter) is GPUImageTransformFilter -> RotateAdjuster(filter) is GPUImageSolarizeFilter -> SolarizeAdjuster(filter) else -> null } }
  24. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ ಈ͖·ͨ͠

  25. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 4. PRΛग़͢ - [x] Color Inversion - [x] Solarize

    - [x] Vibrance - [x] Highlight and Shadow Tint ࡞ͬͨFilterͷCheckboxΛ๨Εͣʹ㾎
  26. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ ௨ৗͷखॱͰPRΛग़ͤ͹OK 4. PRΛग़͢

  27. ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ CLA͕ඞཁͳͷͰɺCONTRIBUTING.mdͷϦϯΫ͔Β 4. PRΛग़͢

  28. ·ͱΊ

  29. ·ͱΊ 1. ௥Ճ͢ΔFilterΛܾΊΔ 2. ຊՈGPUImage2ΛࢀߟʹFilterΛ࣮૷͢Δ 3. sampleͰ࡞ͬͨFilterΛ࢖͑ΔΑ͏ʹ͢Δ 4. PRΛग़͢ ※࠶ܝ

  30. ·ͱΊ ͱͯ΋؆୯

  31. ·ͱΊ Thanks:)