@@ -2,19 +2,11 @@ package com.streamio.videofiltersreactnative.factories
22
33import android.graphics.Bitmap
44import android.graphics.Canvas
5- import com.google.android.gms.tasks.Tasks
65import com.google.android.renderscript.Toolkit
7- import com.google.mlkit.vision.common.InputImage
8- import com.google.mlkit.vision.segmentation.Segmentation
9- import com.google.mlkit.vision.segmentation.SegmentationMask
10- import com.google.mlkit.vision.segmentation.selfie.SelfieSegmenterOptions
116import com.oney.WebRTCModule.videoEffects.VideoFrameProcessor
127import com.oney.WebRTCModule.videoEffects.VideoFrameProcessorFactoryInterface
138import com.streamio.videofiltersreactnative.common.BitmapVideoFilter
14- import com.streamio.videofiltersreactnative.common.Segment
159import com.streamio.videofiltersreactnative.common.VideoFrameProcessorWithBitmapFilter
16- import com.streamio.videofiltersreactnative.common.copySegment
17- import com.streamio.videofiltersreactnative.common.newSegmentationMaskMatrix
1810
1911
2012/* *
@@ -23,35 +15,33 @@ import com.streamio.videofiltersreactnative.common.newSegmentationMaskMatrix
2315 * @param blurIntensity The intensity of the blur effect. See [VideoBlurIntensity] for options. Defaults to [BlurIntensity.MEDIUM].
2416 */
2517class VideoBlurFactory (
26- private val blurIntensity : VideoBlurIntensity = VideoBlurIntensity .MEDIUM
18+ private val blurIntensity : VideoBlurIntensity = VideoBlurIntensity .MEDIUM
2719) : VideoFrameProcessorFactoryInterface {
28- override fun build (): VideoFrameProcessor {
29- return VideoFrameProcessorWithBitmapFilter {
30- BlurredVideoFilter (blurIntensity)
20+ override fun build (): VideoFrameProcessor {
21+ return VideoFrameProcessorWithBitmapFilter {
22+ BlurredVideoFilter (blurIntensity)
23+ }
3124 }
32- }
3325}
3426
3527private class BlurredVideoFilter (
36- private val blurIntensity : VideoBlurIntensity
28+ private val blurIntensity : VideoBlurIntensity
3729) : BitmapVideoFilter() {
3830
39- override fun applyFilter (videoFrameBitmap : Bitmap ) {
40- val blurred = Toolkit .blur(videoFrameBitmap, blurIntensity.radius)
41- val canvas = Canvas (videoFrameBitmap)
42- // Draw the blurred bitmap at the top-left corner (0f, 0f) of the original bitmap.
43- // 0f, 0f: x and y coordinates (top-left corner)
44- // null: use default Paint (no special effects)
45- canvas.drawBitmap(blurred, 0f , 0f , null )
46- }
31+ override fun applyFilter (videoFrameBitmap : Bitmap ) {
32+ val blurred = Toolkit .blur(videoFrameBitmap, blurIntensity.radius)
33+ val canvas = Canvas (videoFrameBitmap)
34+ // Draw the blurred bitmap at the top-left corner (0f, 0f) of the original bitmap.
35+ // 0f, 0f: x and y coordinates (top-left corner)
36+ // null: use default Paint (no special effects)
37+ canvas.drawBitmap(blurred, 0f , 0f , null )
38+ }
4739}
4840
4941/* *
5042 * The intensity of the background blur effect. Used in [BlurredBackgroundVideoFilter].
5143 * Range is 1 to 25
5244 */
5345enum class VideoBlurIntensity (val radius : Int ) {
54- LIGHT (8 ),
55- MEDIUM (17 ),
56- HEAVY (25 ),
57- }
46+ LIGHT (8 ), MEDIUM (17 ), HEAVY (25 ),
47+ }
0 commit comments