aws-samples / amazon-chime-react-native-demo

A React Native demo application for Android and iOS using the Amazon Chime SDK.
MIT No Attribution
101 stars 24 forks source link

Custom Video Source to add skin smoothing filter. #119

Closed Sandip-Z closed 2 years ago

Sandip-Z commented 2 years ago

Our team is trying to add skin smoothing filter. We are following Implementing a custom video processing step for local source from custom_video.md

In NativeMobileSDKBridge.kt, we added

    private val logger = ConsoleLogger(LogLevel.DEBUG);
    private val eglCoreFactory = DefaultEglCoreFactory();
    private val surfaceTextureCaptureSourceFactory = DefaultSurfaceTextureCaptureSourceFactory(logger, eglCoreFactory);
    private val cameraCaptureSource = DefaultCameraCaptureSource(reactContext, logger, surfaceTextureCaptureSourceFactory);

and inside @ReactMethod fun startMeeting(meetingInfo: ReadableMap, attendeeInfo: ReadableMap) method, we added eglCoreFactory in defaultMeetingSession

                    DefaultMeetingSession(
                            it,
                            logger,
                            activity.applicationContext,
                            eglCoreFactory
                    )
                }

and then in setCameraOn method, we did the following:

    fun setCameraOn(enabled: Boolean) {
        logger.info(TAG, "Called setCameraOn: $enabled")
        val myVideoProcessor = GpuVideoProcessor(logger, eglCoreFactory);
        cameraCaptureSource.start()
        cameraCaptureSource.addVideoSink(myVideoProcessor)
        if (enabled) {
          meetingSession?.audioVideo?.startLocalVideo(myVideoProcessor)

        } else {
            meetingSession?.audioVideo?.stopLocalVideo()
        }
    }

GpuVideoProcessor is from demo code provided here

we know this processor turns the camera feed black and white, instead of smoothing it.

Our problem: Our application crashes when we cameraCaptureSource.start()

Any guidance to successfully turn the camera feed into b/w would be appreciated and if you could guide us with adding skin smoothing filter, it would be much much appreciated.

Thank you, have a good day.

zhinang-amazon commented 2 years ago

Hi @Sandip-Z

What is the exception that you are seeing when it crashes? I would also suggest calling cameraCaptureSource.addVideoSink(myVideoProcessor) before cameraCaptureSource.start()

Sandip-Z commented 2 years ago

Hi @zhinang-amazon Thank you for your response. Yes, calling cameraCaptureSource.addVideoSink(myVideoProcessor) before cameraCaptureSource.start() did solve our issue.

Thank you again. 🙇🏾